-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (32 loc) · 1.56 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# https://pipenv.pypa.io/en/latest/basics/#pipenv-and-docker-containers
FROM docker.io/python:3.10 AS base
RUN apt update && \
apt install -y python3-dev libpq-dev
#########################################################
# Builder
#########################################################
FROM base AS builder
RUN pip install --user pipenv
# Tell pipenv to create venv in the current directory
ENV PIPENV_VENV_IN_PROJECT=1
ADD Pipfile.lock Pipfile /usr/src/
WORKDIR /usr/src
# NOTE: If you install binary packages required for a python module, you need
# to install them again in the runtime. For example, if you need to install pycurl
# you need to have pycurl build dependencies libcurl4-gnutls-dev and libcurl3-gnutls
# In the runtime container you need only libcurl3-gnutls
# RUN apt install -y libcurl3-gnutls libcurl4-gnutls-dev
RUN /root/.local/bin/pipenv sync
RUN /usr/src/.venv/bin/python -c "import django; print(django.__version__)"
#########################################################
# Runtime
#########################################################
FROM base AS runtime
RUN mkdir -v /usr/src/venv
COPY --from=builder /usr/src/.venv/ /usr/src/.venv/
COPY . /app
RUN /usr/src/.venv/bin/python -c "import django; print(django.__version__)"
ENV PATH="/usr/src/.venv/bin/:${PATH}"
WORKDIR /app
RUN STATIC_ROOT=/app/static SECRET_KEY=secret_is_irelevent_here DATABASE_URL=sqlite:////dunmmy_db.sqlite3 python manage.py collectstatic --noinput
CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "scorer.asgi:application", "-b", "0.0.0.0:8000"]