Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a comment about Dockerfile deployment #4808

Merged
merged 2 commits into from
Sep 29, 2021

Conversation

francipvb
Copy link
Contributor

I found issues while trying to deploy an app from a dockerfile and I found that the expose instruction causes problems with the dokku proxy. I found the solution and I am contributing it.

I found issues while trying to deploy an app from a dockerfile and I found that the expose instruction causes problems with the dokku proxy.
@josegonzalez
Copy link
Member

When you say it is exposed on the incorrect port, what did you find it was exposed on?

@francipvb
Copy link
Contributor Author

Hello,

The default HTTP port is 80 and if you specify in the dockerfile that you expose the port 8888 you'll have to set up the proxy manually. That means the default nginx page is displayed.

However, if you don't add the EXPOSE instruction the proxy is set up correctly and the application is presented as expected.

@josegonzalez
Copy link
Member

Do you have an example Dockerfile app that doesn't work as expected and the change that you performed to make it work as expected?

@francipvb
Copy link
Contributor Author

Hello,

See this dockerfile:

FROM python:3.9 AS base

ARG DJANGO_SETTINGS_MODULE

WORKDIR /app

RUN pip3 --no-cache-dir install poetry \
    && poetry config virtualenvs.create false

COPY pyproject.toml poetry.lock ./
RUN poetry install --no-dev --no-root

COPY . ./

COPY ./docker/entrypoint.sh /
RUN chmod +x /entrypoint.sh

ENV DJANGO_SETTINGS_MODULE="vectorvgt.settings.runtime"

RUN python manage.py collectstatic --no-input
RUN chmod +x ./docker/post_deploy.sh

EXPOSE 8000
ENTRYPOINT [ "/entrypoint.sh" ]
CMD daphne -b 0.0.0.0 vectorvgt.asgi:application

And here is the procfile:

web: daphne -b 0.0.0.0 -p $PORT vectorvgt.asgi:application
release: python manage.py migrate
worker: celery --application vectorvgt.celery:app worker --events
beat: celery --application vectorvgt.celery:app beat --events

This app won't be presented in the default HTTP port. Insthead the default nginx page will be presented.

To fix this issue, I just removed the EXPOSE instruction.

@josegonzalez
Copy link
Member

Right, when you set an EXPOSE directive and have the nginx proxy enabled, we use that port as the mapping. So nginx listens on port 8000 and routes that to the container. The port mapping is thus http:8000:8000 (scheme:host-port:container-port).

That is documented here under port management (and that section is linked to from here.

Unfortunately, nginx does fallback routing, so if there is already a site set (which is usually something like /etc/nginx/sites-enabled/00-default), then it'll route to that if there is no matching vhost:port server block for the request.

I think your doc link might need a bit more explanation as to why not using an EXPOSE might help. I'll update the PR.

@francipvb
Copy link
Contributor Author

francipvb commented Sep 29, 2021

I see.

What happen if you push changes to the app with the port mapping?

@josegonzalez
Copy link
Member

I think the doc update I wrote clarifies things. Can you check the diff?

@francipvb
Copy link
Contributor Author

Thank you, seems better than mine.

@josegonzalez
Copy link
Member

Awesome, I'll merge it then.

@josegonzalez josegonzalez merged commit 892391a into dokku:master Sep 29, 2021
github-actions bot pushed a commit that referenced this pull request Oct 5, 2021
# History

## 0.25.5

Install/update via the bootstrap script:

```shell
wget https://raw.githubusercontent.com/dokku/dokku/v0.25.5/bootstrap.sh
sudo DOKKU_TAG=v0.25.5 bash bootstrap.sh
```

### Bug Fixes

- #4787: @josegonzalez Do not require double quotes when issuing dokku run commands
- #4816: @josegonzalez Set the DOKKU_HOST_ROOT on docker container start
- #4810: @josegonzalez Handle udp ports when fetching network config
- #4812: @josegonzalez Silence stderr when fetching a command from the Procfile
- #4800: @josegonzalez Add help2man os package for copyfiles make target to devcontainer
- #4796: @josegonzalez Remove the --restart flag from pre-deploy chown containers

### New Features

- #4809: @josegonzalez Implement storage:ensure-directory command
- #4801: @josegonzalez Expose git-from-archive and git-from-image plugin triggers
- #4785: @josegonzalez Add support for VSCode Dev Containers

### Documentation

- #4819: @stephenheron Fixed typo in tar documentation
- #4824: @dy3l Fix GitLab case
- #4822: @josegonzalez Add a note about using the registry:login command for private image deployments
- #4808: @francipvb Added a comment about Dockerfile deployment
- #4807: @FinnWoelm Docs: Fix instructions for enabling Docker Buildkit
- #4786: @josegonzalez Add missing argument from trigger documentation
- #4780: @adam12 Update source for `dokku-update`

### Tests

- #4828: @josegonzalez Update golang in test apps to latest version
- #4815: @josegonzalez tests: use python3 shebang for shellcheck-to-junit script
- #4814: @josegonzalez Add wget to devcontainer to fix shfmt installation
- #4791: @josegonzalez Fix test running in devcontainer

### Other

- #4813: @dependabot[bot] chore(deps-dev): bump heroku/heroku-buildpack-php from 197 to 198 in /tests/apps/php
- #4802: @dependabot[bot] chore(deps): bump django from 3.1.12 to 3.1.13 in /tests/apps/dockerfile-release
- #4784: @josegonzalez Upgrade vector image to 0.16.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants