-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
32 lines (23 loc) · 1.1 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
FROM python:3.12-slim-bookworm
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
RUN mkdir -p /code
WORKDIR /code
# poetry is installed with pip (without caching the package)
RUN pip install --no-cache-dir poetry==1.7.1
# Install dependencies first to speed up docker build (This step is cached and only
# executed when dependency files change)
COPY pyproject.toml poetry.lock /code/
RUN poetry config virtualenvs.create false
RUN poetry install --with django --no-root --no-interaction
# Copy all code to image
COPY . /code
# Create Django migrations (You may remove this when migrations are included in git)
RUN poetry run python manage.py makemigrations --no-input
# Move static assets to STATIC_ROOT
RUN poetry run python manage.py collectstatic --no-input
EXPOSE 8000
# The entrypoint executes two things:
# - "python manage.py migrate". The migrations are applied to the database
# - "gunicorn config.wsgi --bind 0.0.0.0:8000". gunicorn (application server) runs the application
ENTRYPOINT ["/bin/bash", "-c" , "poetry run python manage.py migrate && poetry run gunicorn config.wsgi --bind 0.0.0.0:8000"]