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

docker: Run migrations before starting server #176

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

# ---

Expand Down