a year ago
I have a Django application for which I have a a Dockerfile, it works fine, but for a staging
environment I wish to override the start command.
FROM python:3.10-slim-bullseye
ENV PIP_DISABLE_PIP_VERSION_CHECK 1
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /code
COPY . .
RUN pip install -r requirements.txt
CMD gunicorn core.wsgi --workers=2 --threads=4 --worker-class=gthread --log-file=- --worker-tmp-dir /dev/shm
I created the following json to chain multiple commands including the sleep 3
to wait for the private DNS, but it only executes the first command, I already did a ton of tests, if I remove the sleep
in the deployment logs I get to see only the migrate
command output but the server doesn't execute the gunicorn
. If I remove everything and only leave the gunicorn
it works normally.
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "sleep 3 && python manage.py migrate && gunicorn core.wsgi --workers=2 --threads=4 --worker-class=gthread --log-file=- --worker-tmp-dir /dev/shm",
"restartPolicyType": "NEVER",
"restartPolicyMaxRetries": 10
}
}
0 Replies
a year ago
when using a Dockerfile the start command you set either in the service settings or in the railway.json file is treated as an ENTRYPOINT meaning there is no shell running, &&
does not work without a shell, you would need to wrap your start command in a shell (thats what that syntax of CMD does)
/bin/sh -c "sleep 3 && python manage.py migrate && gunicorn core.wsgi --workers=2 --threads=4 --worker-class=gthread --log-file=- --worker-tmp-dir /dev/shm"
a year ago
no problem!