We're sorry AsposeCloud doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.cloud

How to Deploy Aspose.Words Cloud Docker Container on Heroku?

We saw that 22.1 included a fix WORDSCLOUD-1864 for using the Docker container on Heroku, and are trying this out. However, I’m not sure that the fix works.

Heroku requires that the docker container listen on a port specified by the environment variable $PORT; the default port that the Aspose container uses is not available. So the Aspose Docker container starts, tries to open a port, and crashes with a “System.Net.Sockets.SocketException (13): Permission denied” – because it’s using port 80 or 8082 or something.

If using the docker container on Heroku is indeed fixed, how can I configure the Aspose.Words docker container to listen on a specific port $PORT?

I’ve tried pretty much everything I can on my own here. I’ve found instructions on setting the port for ASP apps, e.g. https://medium.com/dockerbr/publishing-asp-net-core-application-on-heroku-with-docker-cf30072842e2 and https://stackoverflow.com/questions/51004285/net-core-on-heroku-with-docker

Those all suggest to set the port for the env attribute ASPNETCORE_URLS, which I’ve done:

ENV ASPNETCORE_URLS http://+:$PORT
CMD ASPNETCORE_URLS=http://+:$PORT dotnet Aspose.Words.Cloud.WebApp.dll

That’s still throwing the same error on Heroku, though. Seems that the Aspose container isn’t respecting that environment variable.

Error is specifically on Aspose.Words.Cloud.WebApp.Program.Main(String[] args) in C:\Build\src\Aspose.Words.Cloud.WebApp\Program.cs:line 25

@bmulhollandrecital

The referenced bug was about yaml file related issue at following documentation article.

I’m afraid I don’t have knowledge of the Heroku platform. You may please google or ask Heroku developers how to deploy Docker Container in Heroku. For example, you can try to use this stackoverflow answer:

stackoverflow.com

Benjamin Higgins

How can I run a Docker Hub container on Heroku via app.json?

docker, heroku

asked by Benjamin Higgins on 11:12AM - 02 Oct 19 UTC

This isn’t about the Heroku platform anymore. Heroku is working fine. There seems to be a bug that there is no way to make the Aspose Docker container listen on a specific port number – which is generally possible for ASP apps.

So, pretend I never said Heroku. The issue is this: I need the Aspose Docker container to listen on a specific port that is specified at runtime. I have configured ASP to use that port, and the Aspose Container is ignoring the configured port and instead listening at port 80. It should respect the ASP configuration option.

Also: I have Google’d this quite thoroughly, as you can see from my referenced links.

@bmulhollandrecital

Thanks for your detailed feedback. I am looking into the your issue and will update you soon.

@bmulhollandrecital

While investigating the issue, I found that when I run the Aspose.Words Cloud docker container with a custom port, it listens to the requests on the specified port without any issue. I will appreciate it if you please share some details to replicate the issue at my end. It will help us to address your issue.

docker run -p 8101:80 -e "User=tilalahmad" -e "Password=1234567890" -v "./fonts:/fonts" -v "./data:/data" --name aw_213 aspose/words-cloud

Generating Access Token(JWT)

curl -X POST "http://localhost:8101/connect/token" -d "grant_type=client_credentials&client_id=tilalahmad&client_secret=1234567890" -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json"

Hi Tilal, thanks for investigating.

The option you are using is simply providing a middleware firewall rule which uses docker’s published port feature – see here for more information: https://docs.docker.com/config/containers/container-networking/#published-ports

What that means is that the docker container is still opening up port 80 on its host; the docker host is still allowing port 80, and simply redirecting that port to 8101. From the docker container’s perspective, it is still using port 80.

In this situation, the docker container is not permitted to use port 80, and there’s no firewall that can be used to redirect the port. In fact, even if we add a reverse proxy to the docker image (I tried this) that does effectively the same thing you have with -p, that operation still fails because Aspose’s host attempts to open port 80 and does not have permission to do so.

What is needed is to tell the web server that Aspose runs to use a different port. For example, Heroku recommends changing the CMD for a server to be CMD gunicorn --bind 0.0.0.0:$PORT wsgi. Translating it a bit, that command is saying "start a webserver (gunicorn) from any network the computer is attached to (0.0.0.0) and use port $PORT (instead of the default port 80).

You can see that the Aspose docker image configures the port to port 80 in line 4: https://hub.docker.com/layers/aspose/words-cloud/latest/images/sha256-61a4d816c350ee6906aa2bb7bc3f483031f490a9dbd1d65a24b52f3d784d5d13?context=explore. Specifically, it configures an environment variable that tells ASP.NET Core to use port 80, as in “http://+:80”. But when I set that environment variable to a custom port, as you can see in my second post, the Aspose server ignores the configured port and still opens up port 80. And, again, that port 80 is still opened with the command you included – but docker is then opening up fort 8101 also, and redirecting the internal host port 80 to port 8101 on your computer.

FYI, since it’s behind a login, here’s what Heroku says about the PORT requirements:

When deploying a container app on Heroku, we require that Dockerfiles are configured to intake the randomly assigned port on a dyno - exposed as the $PORT environmental variable.

Even though Docker allows for the usage of EXPOSE to specify which port for an image to use, Heroku ignores those commands and goes by the port assigned to a dyno.

For example, instead of this:

PORT=8080
EXPOSE $PORT
CMD gunicorn --bind 0.0.0.0:$PORT wsgi

We ask that you do something like this:

CMD gunicorn --bind 0.0.0.0:$PORT wsgi
1 Like

You can kind of mentally model this as “Aspose and docker shouldn’t know about port 80 in any way. If the configuration says port 80 anywhere, and it’s not overriden by something else, it will not work.”

1 Like

@bmulhollandrecital

Thanks for sharing more details. We have logged a ticket WORDSCLOUD-1937 to further investigate your requirement and implement it accordingly. We will keep you updated about the issuer resolution progress.