-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathDockerfile
45 lines (30 loc) · 1.19 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
FROM python:3.9.13-slim-buster as base
# Setup env
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONFAULTHANDLER 1
FROM base AS python-deps
# Install pipenv and compilation dependencies
RUN pip install --no-cache-dir --upgrade pip==22.2.2 && \
pip install --no-cache-dir pipenv==2022.8.24 gunicorn==20.1.0 django==4.1 django_bootstrap4==22.2 django_extensions==3.2.0 django-allow-cidr==0.5.0 django_q==1.3.9 psycopg2-binary==2.9.3 whitenoise==6.2.0
# Install python dependencies in /.venv
WORKDIR /
COPY Pipfile Pipfile.lock ./
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
FROM base AS runtime
# Install extra packages
RUN apt-get update && \
apt-get install -y --no-install-recommends postgresql-client=11+200+deb10u4 iputils-ping=3:20180629-2+deb10u2 curl=7.64.0-4+deb10u3 && rm -rf /var/lib/apt/lists/*
# Create and switch to a new user
RUN useradd --create-home --uid 1001 --gid 0 appuser
WORKDIR /home/appuser
# Copy virtual env from python-deps stage
COPY --from=python-deps /.venv /.venv
ENV PATH="/.venv/bin:$PATH"
# Install application into container
COPY --chown=1001:0 . .
RUN chmod -R g=u .
USER appuser
EXPOSE 8080
CMD ["bash", "entrypoint.sh"]