-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathDockerfile
91 lines (82 loc) · 3.04 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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2021-present Kaleidos Ventures SL
FROM python:3.11-slim
LABEL maintainer="[email protected]"
# Avoid prompting for configuration
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONFAULTHANDLER=1
# Use a virtualenv
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Get the code
COPY . /taiga-back
WORKDIR /taiga-back
# grab gosu for easy step-down from root
# https://github.com/tianon/gosu/blob/master/INSTALL.md
ENV GOSU_VERSION 1.12
RUN set -eux; \
apt-get update; \
# install system dependencies
apt-get install -y \
build-essential \
gettext \
# libpq5 needed in runtime for psycopg2
libpq5 \
libpq-dev \
git \
net-tools \
procps \
wget; \
# install gosu
apt-get install -y --no-install-recommends ca-certificates wget; \
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
chmod +x /usr/local/bin/gosu; \
# verify gosu signature
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
command -v gpgconf && gpgconf --kill all || :; \
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
# install Taiga dependencies
python -m pip install --upgrade pip; \
python -m pip install wheel; \
python -m pip install -r requirements.txt; \
python -m pip install -r requirements-contribs.txt; \
python manage.py compilemessages; \
python manage.py collectstatic --no-input; \
chmod +x docker/entrypoint.sh; \
chmod +x docker/async_entrypoint.sh; \
cp docker/config.py settings/config.py; \
# create taiga group and user to use it and give permissions over the code (in entrypoint)
groupadd --system taiga --gid=999; \
useradd --system --no-create-home --gid taiga --uid=999 --shell=/bin/bash taiga; \
mkdir -p /taiga-back/media/exports; \
chown -R taiga:taiga /taiga-back; \
# remove unneeded files and packages
apt-get purge -y \
build-essential \
gettext \
git \
libpq-dev \
net-tools \
procps \
wget; \
apt-get autoremove -y; \
rm -rf /var/lib/apt/lists/*; \
rm -rf /root/.cache; \
# clean taiga
rm requirements.txt; \
rm requirements-contribs.txt; \
find . -name '__pycache__' -exec rm -r '{}' +; \
find . -name '*pyc' -exec rm -r '{}' +; \
find . -name '*po' -exec rm -r '{}' +
ENV DJANGO_SETTINGS_MODULE=settings.config
EXPOSE 8000
ENTRYPOINT ["./docker/entrypoint.sh"]