Dockerfile 2.3 KB
Newer Older
1
2
FROM python:3.7
MAINTAINER Thalia Technicie <www@thalia.nu>
Thom Wiggers's avatar
Thom Wiggers committed
3
4
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
# Set up entrypoint and command
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

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

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

Jelle Besseling's avatar
Jelle Besseling committed
39
40
RUN pip install --no-cache-dir poetry && \
    poetry config settings.virtualenvs.create false
Thom Wiggers's avatar
Thom Wiggers committed
41

42
WORKDIR /usr/src/app/website/
Thom Wiggers's avatar
Thom Wiggers committed
43
# install python requirements
Jelle Besseling's avatar
Jelle Besseling committed
44
45
COPY pyproject.toml /usr/src/app/website/
COPY poetry.lock /usr/src/app/website/
46
RUN if [ "$install_dev_requirements" -eq 1 ]; then \
Jelle Besseling's avatar
Jelle Besseling committed
47
        poetry install --no-interaction --extras "docs"; \
48
    else \
Thom Wiggers's avatar
Thom Wiggers committed
49
        echo "This will fail if the dependencies are out of date"; \
Jelle Besseling's avatar
Jelle Besseling committed
50
51
52
        poetry install --no-interaction --extras "docs" --no-dev; \
    fi; \
    poetry cache:clear --all --no-interaction pypi
53

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
RUN chmod +x /usr/local/bin/entrypoint.sh && \
58
    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
RUN sphinx-build -c /usr/src/app/docs/ /usr/src/app/docs/ /usr/src/app/docs/_build && \
    tar --create --xz --file=/usr/src/app/docs.tar.xz --directory=/usr/src/app/docs/_build/ . && \
    rm --recursive /usr/src/app/docs/
69
70
71

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

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