This repository was archived by the owner on Jul 30, 2024. It is now read-only.
forked from City-of-Helsinki/linkedevents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.dist
85 lines (68 loc) · 2.77 KB
/
Dockerfile.dist
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
# Linked Events Dockerfile for distributing the app and running it in dev, test, staging, and production
ARG BASE_IMAGE=python
ARG BASE_IMAGE_VERSION=latest
# ==================================================== #
# Pull the base image
FROM ${BASE_IMAGE}:${BASE_IMAGE_VERSION} AS base
# ==================================================== #
# Set username
ENV USERNAME linkedevents
ENV HOME_DIR /home/${USERNAME}
ENV USER_ID 1000
# Create a new user named linkedevents which should be used to run any software
RUN adduser ${USERNAME} --gecos "" -q --home ${HOME_DIR} --uid ${USER_ID} --disabled-password
# Turn Python's output buffering off, otherwise nothing will show up in Docker's output
ENV PYTHONUNBUFFERED 1
ENV DEBUG false
ENV PRODUCTION true
ENV PATH "${PATH}:${HOME_DIR}/.local/bin"
# Configure timezone and locale
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
RUN set -eux \
&& apt-get update && apt-get -y dist-upgrade \
&& apt-get install -y --no-install-recommends --no-install-suggests \
build-essential \
curl \
gdal-bin \
jq \
locales \
libpq-dev \
tzdata \
wget \
git \
&& ln -fs /usr/share/zoneinfo/Europe/Helsinki /etc/localtime \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& dpkg-reconfigure --frontend noninteractive locales \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
USER ${USERNAME}
WORKDIR ${HOME_DIR}
# .dockerignore is used to only copy the necessary files to the image
COPY --chown=1000 . ./
# Install also awscli so that we can get the db password from SSM parameter store in the admin image
RUN pip install --user --no-cache-dir -r ./requirements.txt \
&& pip install --user --no-cache-dir awscli
EXPOSE 8000
# Define the build and commit args and set default values for them.
# These are used for tracing the image to the commit and build from which the image has been built.
# These should be defined at the bottom since the values change frequently and invalidate the cache causing all later
# layers to be built again.
ARG build=none
ARG commit=none
ENV APP_BUILD $build
ENV APP_COMMIT $commit
# Create labels for build and commit and populate them from the args
LABEL fi.espoo.build=${build}
LABEL fi.espoo.commit=${commit}
# ==================================================== #
FROM base AS dist
# ==================================================== #
ENTRYPOINT ["./entrypoint.dist.sh"]
# ==================================================== #
# AWS Batch job definitions do not allow overriding the entrypoint. Thus, we need to create a separate image with
# another entrypoint suitable for the importers and other administrative tasks.
FROM base AS admin
# ==================================================== #
ENTRYPOINT ["./entrypoint.admin.sh"]