-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
50 lines (38 loc) · 1.46 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
FROM python:3.12-slim
# Needs to be set for users with manually set UID
ENV HOME=/home/document-merge-service
ENV PYTHONUNBUFFERED=1
ENV DJANGO_SETTINGS_MODULE=document_merge_service.settings
ENV APP_HOME=/app
ENV UWSGI_INI=/app/uwsgi.ini
ENV MEDIA_ROOT=/var/lib/document-merge-service/media
ENV DATABASE_DIR=/var/lib/document-merge-service/data
ARG UID=901
RUN mkdir -p $APP_HOME $DATABASE_DIR/tmp $MEDIA_ROOT /var/www/static \
&& useradd -u $UID -r document-merge-service --create-home \
&& mkdir $HOME/.config \
&& chmod -R 770 $DATABASE_DIR $MEDIA_ROOT $HOME /var/www/static \
# All project specific folders need to be accessible by newly created user but
# also for unknown users (when UID is set manually). Such users are in group
# root.
&& chown -R document-merge-service:root $DATABASE_DIR $MEDIA_ROOT $HOME /var/www/static
WORKDIR $APP_HOME
RUN \
--mount=type=cache,target=/var/cache/apt \
apt-get update && apt-get install -y --no-install-recommends \
build-essential \
default-libmysqlclient-dev \
libreoffice-writer \
pkg-config \
unoconv \
util-linux \
wait-for-it \
&& rm -rf /var/lib/apt/lists/*
RUN pip install -U poetry
USER document-merge-service
ARG ENV=docker
COPY pyproject.toml poetry.lock $APP_HOME/
RUN if [ "$ENV" = "dev" ]; then poetry install --all-extras; else poetry install --all-extras --without dev; fi
COPY . $APP_HOME
EXPOSE 8000
CMD /bin/sh -c "poetry run python ./manage.py migrate && poetry run uwsgi"