-
Notifications
You must be signed in to change notification settings - Fork 44
/
Dockerfile
181 lines (138 loc) · 4.43 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
ARG TARGET=archivematica-storage-service
ARG UBUNTU_VERSION=22.04
ARG USER_ID=1000
ARG GROUP_ID=1000
ARG PYTHON_VERSION=3.9
ARG PYENV_DIR=/pyenv
# -----------------------------------------------------------------------------
FROM ubuntu:${UBUNTU_VERSION} AS base-builder
ARG PYENV_DIR=/pyenv
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
libldap2-dev \
libmysqlclient-dev \
libsasl2-dev \
libsqlite3-dev \
locales \
pkg-config \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN locale-gen en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
ENV PYENV_ROOT=${PYENV_DIR}/data
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
# -----------------------------------------------------------------------------
FROM base-builder AS pyenv-builder
ARG PYTHON_VERSION=3.9
RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
libbz2-dev \
libffi-dev \
liblzma-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
libxmlsec1-dev \
tk-dev \
xz-utils \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN set -ex \
&& curl --retry 3 -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash \
&& pyenv install ${PYTHON_VERSION} \
&& pyenv global ${PYTHON_VERSION}
COPY --link requirements-dev.txt /src/requirements-dev.txt
RUN set -ex \
&& pyenv exec python3 -m pip install --upgrade pip setuptools \
&& pyenv exec python3 -m pip install --requirement /src/requirements-dev.txt \
&& pyenv rehash
# -----------------------------------------------------------------------------
FROM base-builder AS base
ARG USER_ID=1000
ARG GROUP_ID=1000
ARG PYENV_DIR=/pyenv
RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
gcc \
gettext \
gnupg1 \
libffi-dev \
libldap2-dev \
libmysqlclient-dev \
libsasl2-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
libz-dev \
media-types \
p7zip-full \
rclone \
rng-tools-debian \
rsync \
unar \
&& rm -rf /var/lib/apt/lists/*
RUN set -ex \
&& groupadd --gid ${GROUP_ID} --system archivematica \
&& useradd --uid ${USER_ID} --gid ${GROUP_ID} --home-dir /var/archivematica --system archivematica
RUN set -ex \
&& internalDirs=' \
/home/archivematica \
/src/storage_service/assets \
/src/storage_service/locations/fixtures \
/var/archivematica/storage_service \
/var/archivematica/sharedDirectory \
' \
&& mkdir -p $internalDirs \
&& chown -R archivematica:archivematica $internalDirs
USER archivematica
COPY --chown=${USER_ID}:${GROUP_ID} --from=pyenv-builder --link ${PYENV_DIR} ${PYENV_DIR}
COPY --chown=${USER_ID}:${GROUP_ID} --link ./install/storage-service.gunicorn-config.py /etc/archivematica/storage-service.gunicorn-config.py
# -----------------------------------------------------------------------------
FROM base AS archivematica-storage-service
ARG USER_ID=1000
ARG GROUP_ID=1000
WORKDIR /src/storage_service
ENV DJANGO_SETTINGS_MODULE=storage_service.settings.local
ENV PYTHONPATH=/src/storage_service
ENV SS_GUNICORN_BIND=0.0.0.0:8000
ENV SS_GUNICORN_CHDIR=/src/storage_service
ENV SS_GUNICORN_ACCESSLOG=-
ENV SS_GUNICORN_ERRORLOG=-
ENV FORWARDED_ALLOW_IPS=*
COPY --chown=${USER_ID}:${GROUP_ID} --link . /src/
RUN set -ex \
&& export SS_DB_URL=mysql://ne:ver@min/d \
&& pyenv exec python3 ./manage.py collectstatic --noinput --clear \
&& pyenv exec python3 ./manage.py compilemessages
ENV DJANGO_SETTINGS_MODULE=storage_service.settings.production
EXPOSE 8000
ENTRYPOINT ["pyenv", "exec", "python3", "-m", "gunicorn", "--config=/etc/archivematica/storage-service.gunicorn-config.py", "storage_service.wsgi:application"]
# -----------------------------------------------------------------------------
FROM base AS archivematica-storage-service-tests
ARG USER_ID=1000
ARG GROUP_ID=1000
USER root
RUN set -ex \
&& python3 -m playwright install-deps firefox \
&& mkdir -p /var/archivematica/.cache/ms-playwright \
&& chown -R archivematica:archivematica /var/archivematica/
USER archivematica
RUN set -ex \
&& python3 -m playwright install firefox
ENV PYTHONPATH=/src/storage_service
COPY --chown=${USER_ID}:${GROUP_ID} --link . /src/
# -----------------------------------------------------------------------------
FROM ${TARGET}