-
Notifications
You must be signed in to change notification settings - Fork 89
/
Dockerfile
89 lines (71 loc) · 2.66 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
80
81
82
83
84
85
86
87
88
89
# syntax=docker/dockerfile:1
FROM registry.gitlab.com/vstconsulting/images:ubuntu AS build
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
WORKDIR /usr/local/polemarch
ENV CC='ccache gcc'
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \
--mount=type=cache,target=/root/.cache/pip \
apt update && \
apt -y install --no-install-recommends \
default-libmysqlclient-dev \
libpcre3-dev \
python3.8-dev \
libldap2-dev \
libsasl2-dev \
libffi-dev \
libkrb5-dev \
krb5-multidev \
libssl-dev \
libpq-dev \
gcc
COPY . .
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=cache,target=/cache \
--mount=type=cache,target=/usr/local/polemarch/.tox \
tox -e build_for_docker
###############################################################
FROM registry.gitlab.com/vstconsulting/images:python as production
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
ARG PACKAGE_NAME=polemarch
ENV WORKER=ENABLE \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
POLEMARCH_UWSGI_LIMITS=1536 \
POLEMARCH_UWSGI_PIDFILE=/tmp/web.pid \
POLEMARCH_PROJECTS_DIR=/projects \
POLEMARCH_SQLITE_DIR=/var/lib/polemarch/
RUN --mount=type=cache,target=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt \
--mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,from=build,source=/usr/local/polemarch/,target=/polemarch_env \
apt update && \
apt -y install --no-install-recommends \
git \
sudo \
sshpass \
libmysqlclient21 \
libpq5 \
libpcre3 \
libldap-2.4-2 \
libsasl2-2 \
libffi7 \
libssl1.1 \
openssh-client && \
python3.8 -m pip install cryptography paramiko 'pip<22' && \
ln -s /usr/bin/python3.8 /usr/bin/python && \
mkdir -p /projects /hooks /run/openldap /etc/polemarch/hooks /var/lib/polemarch && \
python3.8 -m pip install --no-index --find-links /polemarch_env/wheels $PACKAGE_NAME[mysql,postgresql,ansible] && \
find /usr/lib/python3.8 -regex '.*\(*.pyc\|__pycache__\).*' -delete && \
apt autoremove -y && \
rm -rf /tmp/* \
/var/tmp/* \
/var/log/apt/*
RUN useradd -m -s /bin/bash -U -u 1000 polemarch && \
chown -R polemarch /projects /hooks /run/openldap /etc/polemarch /var/lib/polemarch && \
ln -s /usr/bin/python3.8 /usr/local/bin/python
USER polemarch
WORKDIR /home/polemarch
EXPOSE 8080
ENTRYPOINT []
CMD ["/usr/local/bin/polemarchctl", "dockerrun"]