-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
75 lines (62 loc) · 2.28 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
FROM python:3.12-slim
ARG DJANGO_ENV
ENV DJANGO_ENV=${DJANGO_ENV} \
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
PIPENV_HIDE_EMOJIS=true \
NO_COLOR=true \
PIPENV_NOSPIN=true \
DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
bash \
gettext \
postgresql-client \
tree \
curl \
libevent-dev \
rsync \
cron \
nano \
git \
&& rm -rf /var/cache/apt/ \
&& rm -rf /var/lib/apt/lists/*
# create directories
RUN mkdir -p /usr/src/app && \
mkdir -p /usr/src/app/staticfiles && \
mkdir -p /usr/src/app/infoscience_exports && \
mkdir -p /var/log/django
WORKDIR /usr/src/app
# install requirements
COPY ./Pipfile /usr/src/app/Pipfile
COPY ./Pipfile.lock /usr/src/app/Pipfile.lock
RUN pip install pipenv
RUN /bin/bash -c 'pipenv install $(test "$DJANGO_ENV" == production || echo "--dev") --deploy --system --ignore-pipfile'
# copy project files
COPY ./update_release.py /usr/src/app/update_release.py
COPY ./infoscience_exports/exports/versions.py /usr/src/app/versions.py
COPY ./Makefile /usr/src/app/Makefile
COPY ./infoscience_exports /usr/src/app/infoscience_exports
# collectstatic
RUN DJANGO_SETTINGS_MODULE=settings.prod \
SECRET_KEY="not needed to collectstaticfiles" \
ALLOWED_HOSTS="not needed to collectstaticfiles" \
SITE_URL="not needed to collectstaticfiles" \
DATABASE_URL="not needed to collectstaticfiles" \
python infoscience_exports/manage.py collectstatic
# compilemessages
RUN DJANGO_SETTINGS_MODULE=settings.prod \
SECRET_KEY="not needed to compilemessages" \
ALLOWED_HOSTS="not needed to compilemessages" \
SITE_URL="not needed to compilemessages" \
DATABASE_URL="not needed to compilemessages" \
python infoscience_exports/manage.py compilemessages
VOLUME ["/usr/src/app/staticfiles", "/var/log/django", "/usr/src/app/coverage.xml"]
# set the root group advanced permissions, in case of live change
RUN chmod g+rwx -R /usr/src/app
EXPOSE 3000
CMD ["gunicorn", "--bind", ":3000", "--workers", "2", "--chdir", "/usr/src/app/infoscience_exports", "wsgi:application"]