Skip to content
Snippets Groups Projects
Dockerfile 1.81 KiB
Newer Older
FROM python:3.7
MAINTAINER Thalia Technicie <www@thalia.nu>
Thom Wiggers's avatar
Thom Wiggers committed
LABEL description="Contains the Thaliawebsite Django application"

# Arguments
ARG install_dev_requirements=1
ARG source_commit="unknown"
Thom Wiggers's avatar
Thom Wiggers committed
# Try to keep static operation on top to maximise Docker cache utilisation

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

# Set up entrypoint and command
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

# 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 && \
    mkdir -p /usr/src/app && \
    mkdir -p /usr/src/app/website
Thom Wiggers's avatar
Thom Wiggers committed

# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
Thom Wiggers's avatar
Thom Wiggers committed
    postgresql-client \
    gettext \
    ghostscript && \
    rm -rf /var/lib/apt
Jelle Besseling's avatar
Jelle Besseling committed
RUN pip install --no-cache-dir poetry && \
    poetry config settings.virtualenvs.create false
WORKDIR /usr/src/app/website/
Thom Wiggers's avatar
Thom Wiggers committed
# install python requirements
Jelle Besseling's avatar
Jelle Besseling committed
COPY pyproject.toml /usr/src/app/website/
COPY poetry.lock /usr/src/app/website/
RUN if [ "$install_dev_requirements" -eq 1 ]; then \
        poetry install --no-interaction; \
Thom Wiggers's avatar
Thom Wiggers committed
        echo "This will fail if the dependencies are out of date"; \
        poetry install --no-interaction --no-dev; \
Jelle Besseling's avatar
Jelle Besseling committed
    fi; \
    poetry cache:clear --all --no-interaction pypi
# Create entry points
COPY resources/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY resources/entrypoint_production.sh /usr/local/bin/entrypoint_production.sh
RUN chmod +x /usr/local/bin/entrypoint.sh && \
    chmod +x /usr/local/bin/entrypoint_production.sh
Thom Wiggers's avatar
Thom Wiggers committed
# copy app source
COPY website /usr/src/app/website/

RUN echo "Don't build releases yourself, let CI do it!"