Dockerfile 1.98 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
7
# Arguments
ARG install_dev_requirements=1

Thom Wiggers's avatar
Thom Wiggers committed
8
9
10
11
12
# 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
13
ENV DEBIAN_FRONTEND=noninteractive
Thom Wiggers's avatar
Thom Wiggers committed
14

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

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

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

38
WORKDIR /usr/src/app/website/
Thom Wiggers's avatar
Thom Wiggers committed
39
# install python requirements
40
41
42
43
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
44
45
RUN pip install --no-cache-dir \
    -r requirements.txt \
Thom Wiggers's avatar
Thom Wiggers committed
46
    -r production-requirements.txt \
47
    -r ../docs/requirements.txt
Thom Wiggers's avatar
Thom Wiggers committed
48

49
50
51
52
53
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
54
55
56
# Create entry points
COPY resources/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY resources/entrypoint_production.sh /usr/local/bin/entrypoint_production.sh
Thom Wiggers's avatar
Thom Wiggers committed
57
58
RUN chmod +x /usr/local/bin/entrypoint.sh && \
    chmod +x /usr/local/bin/entrypoint_production.sh
Thom Wiggers's avatar
Thom Wiggers committed
59

Thom Wiggers's avatar
Thom Wiggers committed
60
# copy app source
61
62
63
64
65
COPY website /usr/src/app/website/

# Copy files for Sphinx documentation
COPY README.md /usr/src/app/
COPY docs /usr/src/app/docs
66
67
68

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

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