Dockerfile 2.16 KB
Newer Older
Thom Wiggers's avatar
Thom Wiggers committed
1
FROM python:3.5
Thom Wiggers's avatar
Thom Wiggers committed
2
3
4
MAINTAINER Thom Wiggers <thom@thomwiggers.nl>
LABEL description="Contains the Thaliawebsite Django application"

5
6
# Arguments
ARG install_dev_requirements=1
7
ARG source_commit="unknown"
8

Thom Wiggers's avatar
Thom Wiggers committed
9
10
11
12
13
# Try to keep static operation on top to maximise Docker cache utilisation

# Disable output buffering
ENV DJANGO_PRODUCTION 1
ENV PYTHONUNBUFFERED 1
Thom Wiggers's avatar
Thom Wiggers committed
14
ENV DEBIAN_FRONTEND=noninteractive
15
ENV SOURCE_COMMIT=${source_commit}
Thom Wiggers's avatar
Thom Wiggers committed
16

17
18
19
20
# Set up entrypoint and command
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["--help"]

Thom Wiggers's avatar
Thom Wiggers committed
21
22
23
24
25
26
# Create /concrexit dir
# Create log dir and log file
# Create app dir
RUN mkdir /concrexit && \
    mkdir -p /concrexit/log/ && \
    touch /concrexit/log/uwsgi.log && \
27
    mkdir -p /concrexit/docs/ && \
Thom Wiggers's avatar
Thom Wiggers committed
28
    chown -R www-data:www-data /concrexit && \
29
30
31
    mkdir -p /usr/src/app && \
    mkdir -p /usr/src/app/website && \
    mkdir -p /usr/src/app/docs
Thom Wiggers's avatar
Thom Wiggers committed
32
33

# Install dependencies
Thom Wiggers's avatar
Thom Wiggers committed
34
RUN apt-get update && apt-get install -y --no-install-recommends \
Thom Wiggers's avatar
Thom Wiggers committed
35
    postgresql-client \
Thom Wiggers's avatar
Thom Wiggers committed
36
37
38
    gettext \
    ghostscript && \
    rm -rf /var/lib/apt
Thom Wiggers's avatar
Thom Wiggers committed
39

40
WORKDIR /usr/src/app/website/
Thom Wiggers's avatar
Thom Wiggers committed
41
# install python requirements
42
43
44
45
COPY requirements.txt /usr/src/app/website/
COPY production-requirements.txt /usr/src/app/website/
COPY dev-requirements.txt /usr/src/app/website/
COPY docs/requirements.txt /usr/src/app/docs/
Thom Wiggers's avatar
Thom Wiggers committed
46
47
RUN pip install --no-cache-dir \
    -r requirements.txt \
Thom Wiggers's avatar
Thom Wiggers committed
48
    -r production-requirements.txt \
49
    -r ../docs/requirements.txt
Thom Wiggers's avatar
Thom Wiggers committed
50

51
52
53
54
55
RUN if [ "$install_dev_requirements" -eq 1 ]; then \
    pip install --no-cache-dir -r dev-requirements.txt; \
    fi


Thom Wiggers's avatar
Thom Wiggers committed
56
57
58
# Create entry points
COPY resources/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY resources/entrypoint_production.sh /usr/local/bin/entrypoint_production.sh
59
COPY resources/entrypoint_celery.sh /usr/local/bin/entrypoint_celery.sh
Thom Wiggers's avatar
Thom Wiggers committed
60
RUN chmod +x /usr/local/bin/entrypoint.sh && \
61
62
    chmod +x /usr/local/bin/entrypoint_production.sh && \
    chmod +x /usr/local/bin/entrypoint_celery.sh
Thom Wiggers's avatar
Thom Wiggers committed
63

Thom Wiggers's avatar
Thom Wiggers committed
64
# copy app source
65
66
67
68
69
COPY website /usr/src/app/website/

# Copy files for Sphinx documentation
COPY README.md /usr/src/app/
COPY docs /usr/src/app/docs
70
71
72

# Cache docs between builds if not mounting to FS
VOLUME /concrexit/docs
73

Thom Wiggers's avatar
Thom Wiggers committed
74
RUN echo "Don't build releases yourself, let CI do it!"