Dockerfile 1.81 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 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 && \
    chown -R www-data:www-data /concrexit && \
27
    mkdir -p /usr/src/app && \
28
    mkdir -p /usr/src/app/website
Thom Wiggers's avatar
Thom Wiggers committed
29 30

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

Jelle Besseling's avatar
Jelle Besseling committed
37 38
RUN pip install --no-cache-dir poetry && \
    poetry config settings.virtualenvs.create false
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
Jelle Besseling's avatar
Jelle Besseling committed
42 43
COPY pyproject.toml /usr/src/app/website/
COPY poetry.lock /usr/src/app/website/
44
RUN if [ "$install_dev_requirements" -eq 1 ]; then \
45
        poetry install --no-interaction; \
46
    else \
Thom Wiggers's avatar
Thom Wiggers committed
47
        echo "This will fail if the dependencies are out of date"; \
48
        poetry install --no-interaction --no-dev; \
Jelle Besseling's avatar
Jelle Besseling committed
49 50
    fi; \
    poetry cache:clear --all --no-interaction pypi
51

Thom Wiggers's avatar
Thom Wiggers committed
52 53 54
# 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
55
RUN chmod +x /usr/local/bin/entrypoint.sh && \
56
    chmod +x /usr/local/bin/entrypoint_production.sh
Thom Wiggers's avatar
Thom Wiggers committed
57

Thom Wiggers's avatar
Thom Wiggers committed
58
# copy app source
59 60
COPY website /usr/src/app/website/

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