-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
100 lines (76 loc) · 3.1 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# syntax = docker/dockerfile:1.5
# use osgeo gdal ubuntu small 3.10.0 image.
FROM ghcr.io/osgeo/gdal:ubuntu-small-3.10.0
ARG UID
ENV UID=${UID:-9999}
ARG GID
ENV GID=${GID:-9999}
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# We might be running as a user which already exists in this image. In that situation
# Everything is OK and we should just continue on.
RUN groupadd -g $GID alertwise_docker_group || exit 0
RUN useradd --shell /bin/bash -u $UID -g $GID -o -c "" -m alertwise_docker_user -l || exit 0
ENV DOCKER_USER=alertwise_docker_user
ENV POSTGRES_VERSION=15
# Install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
lsb-release \
ca-certificates \
gnupg2 \
curl \
tini \
libpq-dev \
libgeos-dev \
imagemagick \
libmagic1 \
libcairo2-dev \
libpangocairo-1.0-0 \
libffi-dev \
python3-pip \
python3-dev \
python3-venv \
poppler-utils \
git \
gosu \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& curl --silent https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
postgresql-client-$POSTGRES_VERSION \
&& apt-get autoclean \
&& apt-get clean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/*
ARG DOCKER_COMPOSE_WAIT_VERSION
ENV DOCKER_COMPOSE_WAIT_VERSION=${DOCKER_COMPOSE_WAIT_VERSION:-2.12.1}
ARG DOCKER_COMPOSE_WAIT_PLATFORM_SUFFIX
ENV DOCKER_COMPOSE_WAIT_PLATFORM_SUFFIX=${DOCKER_COMPOSE_WAIT_PLATFORM_SUFFIX:-}
# Install docker-compose wait
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/$DOCKER_COMPOSE_WAIT_VERSION/wait${DOCKER_COMPOSE_WAIT_PLATFORM_SUFFIX} /wait
RUN chown $UID:$GID /wait && chmod +x /wait
# Create directories and set correct permissions
RUN mkdir -p /alertwise/app && chown -R $UID:$GID /alertwise
USER $UID:$GID
COPY ./alertwise/requirements/standalone.txt /alertwise/requirements/
RUN python3 -m venv /alertwise/venv
ENV PIP_CACHE_DIR=/tmp/alertwise_pip_cache
# hadolint ignore=SC1091,DL3042
RUN --mount=type=cache,mode=777,target=$PIP_CACHE_DIR,uid=$UID,gid=$GID . /alertwise/venv/bin/activate && \
pip3 install -r /alertwise/requirements/standalone.txt
COPY --chown=$UID:$GID ./alertwise /alertwise/app
# Create a tmp directory for the django to use
RUN mkdir -p /alertwise/tmp && chown -R $UID:$GID /alertwise/tmp
WORKDIR /alertwise/app
# Ensure that Python outputs everything that's printed inside
# the application rather than buffering it.
ENV PYTHONUNBUFFERED 1
# install alertwise as a package
RUN chmod a+x /alertwise/app/docker/docker-entrypoint.sh && \
/alertwise/venv/bin/pip install --no-cache-dir -e /alertwise/app/
ENTRYPOINT ["/usr/bin/tini", "--", "/bin/bash", "/alertwise/app/docker/docker-entrypoint.sh"]
# Add the venv to the path. This ensures that the venv is always activated when the container starts.
ENV PATH="/alertwise/venv/bin:$PATH"
ENV DJANGO_SETTINGS_MODULE='alertwise.config.settings.production'
CMD ["gunicorn"]