This repository has been archived by the owner on Jan 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile
79 lines (61 loc) · 1.96 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
########
# This image compile the dependencies
########
FROM arkhn/python-db-drivers:0.3.0 as compile-image
ENV VIRTUAL_ENV /srv/venv
ENV PATH "${VIRTUAL_ENV}/bin:${PATH}"
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
WORKDIR /srv
RUN apt-get update \
&& ACCEPT_EULA=Y apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
binutils \
build-essential \
libpq-dev \
# git is unfortunately required for company packages
# that have not been published on pypi (yet)
git \
&& apt-get autoremove --purge -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
RUN python -m venv ${VIRTUAL_ENV}
COPY requirements requirements
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
RUN pip install --no-cache-dir -r requirements/prod.txt
RUN pip install --no-cache-dir -r requirements/tests.txt
########
# This image is the runtime
########
FROM arkhn/python-db-drivers:0.3.0 as runtime-image
ARG VERSION_SHA
ARG VERSION_NAME
ENV VERSION_SHA $VERSION_SHA
ENV VERSION_NAME $VERSION_NAME
ENV VIRTUAL_ENV /srv/venv
ENV PATH "${VIRTUAL_ENV}/bin:${PATH}"
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1
WORKDIR /srv
RUN apt-get update \
&& ACCEPT_EULA=Y apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
curl libpq-dev \
&& apt-get autoremove --purge -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd uwsgi
RUN useradd --no-log-init -g uwsgi uwsgi
# Copy venv with compiled dependencies
COPY --chown=uwsgi:uwsgi --from=compile-image /srv/venv /srv/venv
COPY --chown=uwsgi:uwsgi ["pyproject.toml", "docker-entrypoint.sh", "uwsgi.ini", "/srv/"]
COPY --chown=uwsgi:uwsgi django /srv/django
COPY --chown=uwsgi:uwsgi tests /srv/tests
COPY --chown=uwsgi:uwsgi tox.ini /srv/tox.ini
RUN chmod +x docker-entrypoint.sh
RUN mkdir -p /var/www/static
RUN chown uwsgi:uwsgi /var/www/static
VOLUME /var/www/static
USER uwsgi
EXPOSE 8000
ENTRYPOINT ["/srv/docker-entrypoint.sh"]