-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathDockerfile
48 lines (41 loc) · 1.45 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
ARG PYTHON_VERSION="3.7"
FROM python:${PYTHON_VERSION}-slim as builder
ENV PYTHONUNBUFFERED 1
RUN apt-get update \
&& apt-get install -y \
libmariadbclient-dev-compat \
gcc \
wait-for-it \
gettext \
make \
&& rm -rf /var/lib/apt/lists/*
# make - required for docs build
# wait-for-it - required for dependencies waiting eg. wait to database start
# gcc - for required for some python
# gettext - regenerate locales
WORKDIR /code
COPY requirements/*.txt /code/requirements/
RUN pip install --no-cache-dir pip wheel -U
VOLUME /code/media
VOLUME /code/static
EXPOSE 8000
# PRODUCTION SETTINGS
FROM builder AS prod_settings
ENV DJANGO_SETTINGS_MODULE="config.settings.production"
ENV REQS_FILE="requirements/production.txt"
# DEVELOPMENT SETTINGS
FROM builder AS dev_settings
ENV DJANGO_SETTINGS_MODULE="config.settings.development"
ENV REQS_FILE="requirements/development.txt"
# PRODUCTION BUILD
FROM prod_settings AS prod
RUN pip install --no-cache-dir -r $REQS_FILE
COPY . /code/
# timeout increased due slow loading of pyparsing
CMD ["bash", "-c", "python manage.py collectstatic --no-input && python manage.py migrate && gunicorn -w 3 -b 0.0.0.0:8000 --timeout 60 config.wsgi"]
# DEVELOPMENT BUILD
FROM dev_settings AS dev
# Add git required by coveralls
RUN pip install --no-cache-dir -r $REQS_FILE
COPY . /code/
CMD ["bash", "-c", "python manage.py collectstatic --no-input && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]