From 0386b3819f9e45e2f2a94c3ffc7ab6ae260b6d09 Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 17 Dec 2023 09:51:26 -0500 Subject: [PATCH] Use shell form of CMD to run migrations before starting server --- Dockerfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index df10a06..49103ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,19 +8,26 @@ RUN npm run build # --- FROM python:3.11-alpine AS backend + RUN apk add build-base python3-dev jpeg-dev zlib-dev libffi-dev ENV LIBRARY_PATH=/lib:/usr/lib WORKDIR /app +# install python dependencies from project requirements.txt COPY requirements.txt /app RUN pip3 install -r requirements.txt gunicorn --no-cache-dir +# pull in the actual app +# TODO: refine this to pull in less things COPY . /app + +# pull in built frontend files and drop them into the django static directory COPY --from=frontend-builder /build/dist /app/frontend/dist RUN DJANGO_SECRET_KEY=static python3 ./manage.py collectstatic + EXPOSE 8000 -ENTRYPOINT ["python3"] -CMD ["/usr/local/bin/gunicorn", "surveysite.wsgi", "--bind", "0.0.0.0:8000"] +CMD python3 ./manage.py migrate \ + && python3 /usr/local/bin/gunicorn surveysite.wsgi --bind 0.0.0.0:8000 # ---