This repository has been archived by the owner on Apr 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
executable file
·142 lines (113 loc) · 4.25 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# load additional data without downloading it everytime osmaxx sources change!
FROM ubuntu:focal-20220302 as extra-data
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y \
wget \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /additional_data/
# Fetch required additional data for Garmin as documented http://www.mkgmap.org.uk/download/mkgmap.html
RUN wget -nv --show-progress --progress=bar:force:noscroll -c --tries=20 --read-timeout=20 -O /additional_data/bounds.zip http://osm.thkukuk.de/data/bounds-latest.zip \
&& wget -nv --show-progress --progress=bar:force:noscroll -c --tries=20 --read-timeout=20 -O /additional_data/sea.zip http://osm.thkukuk.de/data/sea-latest.zip
# This GDAL image comes with support for FileGDB and has Python 3.8 already installed.
# Based on image osgeo/gdal (which itself is derived from _/ubuntu).
FROM geometalab/gdal:full-v3.4.1 as base
USER root
ENV PYTHONUNBUFFERED=rununbuffered \
PYTHONIOENCODING=utf-8 \
SHELL=/bin/bash \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
LANGUAGE=en_US.UTF-8 \
PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
MAX_POETRY_VERSION=2 \
DOCKERIZE_VERSION=v0.6.1
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y \
git \
libpq-dev \
locales \
wget \
ca-certificates \
python3-distutils \
python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
# Enable prompt color in the skeleton .bashrc before creating the default USERNAME
&& sed -i 's/^#force_color_prompt=yes/force_color_prompt=yes/' /etc/skel/.bashrc
# use a more recent pip version to avoid issues
# with certificates being too old and stuff like that...
RUN wget -O get-pip.py https://bootstrap.pypa.io/get-pip.py \
&& python get-pip.py \
&& rm get-pip.py
ENV USER=py \
HOME=/home/py \
WORKDIR=/home/py/osmaxx
RUN useradd -d $HOME --uid 1000 --gid 100 -m $USER
WORKDIR ${WORKDIR}
# don't put on same line, workdir isn't set at the moment
ENV PYTHONPATH="${PYTHONPATH}:${WORKDIR}"
RUN pip install -U "poetry<$MAX_POETRY_VERSION" \
&& poetry config virtualenvs.create false
COPY ./poetry.lock ./pyproject.toml ${WORKDIR}/
RUN poetry install --no-interaction --no-ansi
# RUN python -m pip install --no-cache-dir install "poetry<$MAX_POETRY_VERSION" \
# && poetry export --dev -f requirements.txt --output requirements.txt \
# && pip install -r requirements.txt
########################
##### FRONTEND #########
########################
FROM base as frontend
ENV NUM_WORKERS=5 \
DATABASE_HOST=frontenddatabase \
DATABASE_PORT=5432
EXPOSE 8000
COPY ./osmaxx ${WORKDIR}/osmaxx
COPY ./web_frontend ${WORKDIR}/web_frontend
WORKDIR ${WORKDIR}/web_frontend
CMD gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 3
########################
####### WORKER #########
########################
FROM base as worker
WORKDIR /var/data/garmin/additional_data/
COPY --from=extra-data /additional_data /var/data/garmin/additional_data
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
RUN apt-get update \
&& apt-get install -y \
apt-utils \
locales \
gpg \
curl \
ca-certificates \
gnupg \
osm2pgsql \
&& rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
RUN apt-get update && \
apt-get install -y \
\
make cmake g++ libboost-dev libboost-system-dev \
libboost-filesystem-dev libexpat1-dev zlib1g-dev \
libbz2-dev libpq-dev lua5.2 liblua5.2-dev \
libproj-dev \
curl git wget \
libstdc++6 \
osmctools \
osmium-tool \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY ./osmaxx ${WORKDIR}/osmaxx
COPY ./web_frontend ${WORKDIR}/web_frontend
WORKDIR ${WORKDIR}/web_frontend