-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
55 lines (35 loc) · 1.24 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
54
55
FROM python:3.10-slim as base
LABEL maintainer="[email protected]"
# use bash
SHELL ["/bin/bash", "-c"]
# install any security updates
RUN apt-get update && apt-get -y upgrade
# upgrade pip and install poetry
RUN pip install --upgrade pip && pip install "poetry>=1.4.2"
WORKDIR /datalab
# copy bare minimum needed to install python dependecies with poetry
COPY ./README.md ./pyproject.toml ./poetry.lock ./
RUN pip install gunicorn[gevent]==21.2.0
RUN pip install -r <(poetry export)
# copy everything else
COPY ./ ./
# install our app
RUN pip install .
# collect all static assets into one place: /static
RUN mkdir -p static && python manage.py collectstatic --noinput
ENV PYTHONUNBUFFERED=1 PYTHONFAULTHANDLER=1
# add a multi-stage build target which also has dev (test) dependencies
# usefull for running tests in docker container
# this won't be included in the final image
# e.g. docker build --target dev .
FROM base as dev
RUN pip install -r <(poetry export --dev)
ENTRYPOINT ["bash"]
# final image
FROM base as prod
# add a non-root user to run the app
RUN useradd appuser
# switch to non-root user
USER appuser
CMD ["gunicorn", "datalab.wsgi", "--bind=0.0.0.0:8080", "--worker-class=gevent", "--workers=4", "--timeout=300"]
EXPOSE 8080/tcp