coderedcms
coderedcms copied to clipboard
I have a problem hosting mysite in a Docker container.
I have a problem hosting mysite in a Docker container.
The instruction is usually https://docs.coderedcorp.com/wagtail-crx/how_to/docker.html.
But my container is not waking up. /bin/sh: 1: exec: waitress: not found
I chose the first way to do it. Because the second way doesn't work, probably.
My Dockerfile
FROM python:3.10.5
ENV PYTHONUNBUFFERED 1
Set the Django settings to use.
ENV DJANGO_ENV "dev" ENV DJANGO_SETTINGS_MODULE "mysite.settings.dev"
Install a WSGI server into the container image.
RUN pip install waitress
Code will end up living in /app/
WORKDIR /app/
Copy and install the project requirements.
COPY ./requirements.txt /app/requirements.txt RUN pip install -r /app/requirements.txt
Copy the entire project code.
COPY . /app/
Prepare the app.
RUN python manage.py migrate RUN python manage.py collectstatic --noinput
Create a "coderedcms" user account to run the app.
RUN useradd coderedcms RUN chown -R coderedcms /app/ USER coderedcms
Finally, run the app on port 8000.
EXPOSE 8000 CMD exec waitress serve --listen "*:8000" "mysite.wsgi:application"
Step 2: Build Image. I do in folder mysite, PowerShell: docker build --pull -t myproject:v1 . Step 3: Run a Container Using the Image docker run --publish 8000:8000 --detach --name myproject-run myproject:v1 So, I go to http://localhost:8000/
and I have ERR_CONNECTION_REFUSED
Sorry. Help me please.
Second way in PowerShell: When I do docker build --pull -t myproject:v3 . PS C:\Alex\WagtailCRX\mysite> docker build --pull -t myproject:v3 . [+] Building 27.6s (4/4) FINISHED => [internal] load build definition from Dockerfile 0.6s => => transferring dockerfile: 32B 0.0s => [internal] load .dockerignore 0.6s => => transferring context: 2B 0.0s => ERROR [internal] load metadata for docker.io/library/python:3.10.5 25.7s => [auth] library/python:pull token for registry-1.docker.io 0.0s
[internal] load metadata for docker.io/library/python:3.10.5:
failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to authorize: rpc error: code = Unknown desc = failed to fetch oauth token: Get "https://auth.docker.io/token?scope=repository%3Alibrary%2Fpython%3Apull&service=registry.docker.io": dial tcp: lookup auth.docker.io: no such host Dockerfile FROM python:3.10.5
ENV PYTHONUNBUFFERED 1
Set the Django settings to use.
ENV DJANGO_ENV "dev" ENV DJANGO_SETTINGS_MODULE "mysite.settings.dev"
Install a WSGI server into the container image.
RUN pip install waitress
Code will end up living in /app/
WORKDIR /app/
Create a "coderedcms" user account to run the appp.
RUN useradd coderedcms RUN chown -R coderedcms /app/ USER coderedcms
Copy our entrypoint script.
COPY ./docker-entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/docker-entrypoint.sh
Finally, run the app on port 8000.
EXPOSE 8000 ENTRYPOINT ["docker-entrypoint.sh"] CMD exec waitress serve --listen "*:8000" "mysite.wsgi:application"
docker-entrypoint.sh pip install -r requirements.txt python manage.py migrate python manage.py collectstatic --noinput
Hi! I'm making a Production Ready Docker Image for WagtailCRX. I'm using Gunicorn instead Waitress. Maybe it helps somehow.
If it's not finding waitress... it is possible something isn't building correctly. Can you run the docker build
command, then paste the output of it here?. Hint... put the pasted output in triple backticks ```
in the github markdown to preserve the formatting.
@alexandorall The solution is much easier as the waitress command is not waitress serve
, but waitress-serve
. Then everything should run as it should ;)
@vsalvino here is the Mini-PR https://github.com/coderedcorp/coderedcms/pull/564/files