forked from rodrigorega/CatAtom2Osm
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
63 lines (51 loc) · 1.34 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
ARG APP_ENV=prod
ARG user=catastro
ARG group=catastro
ARG home=/catastro
FROM ubuntu:20.04 AS base
LABEL maintainer="[email protected]"
ARG APP_ENV
ARG REQUISITES=requisites-$APP_ENV.txt
ARG user
ARG group
ARG home
ARG uid=1000
ARG gid=1000
# System deps
ENV APP_PATH=/opt/CatAtom2Osm
ENV PYTHONPATH=$APP_PATH
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y \
&& apt-get upgrade -y \
&& apt-get install -y language-pack-es-base language-pack-ca-base \
language-pack-gl-base language-pack-eu-base python3 python3-pip git qgis \
nano gettext
ENV LANG=es_ES.UTF-8
ENV PYTHONIOENCODING=utf-8
ENV QT_QPA_PLATFORM=offscreen
# Create application user and home
RUN (mkdir -p "$home" && chown $uid:$gid "$home" \
&& addgroup --gid $gid $group \
&& useradd -d "$home" -u $uid -g $group -s /bin/bash $user) || true
RUN mkdir -p "/tmp/runtime-$user" \
&& chown $uid:$gid "/tmp/runtime-$user"
ENV XDG_RUNTIME_DIR="/tmp/runtime-$user"
# Copy only requirements to cache them in docker layer
WORKDIR $APP_PATH
COPY $REQUISITES ./
RUN pip install -r $REQUISITES
# Copy install
COPY bin ./bin/
COPY Makefile ./
RUN make install
FROM base AS prod_stage
ONBUILD COPY . .
FROM base AS dev_stage
ONBUILD RUN echo "Skip copy"
FROM ${APP_ENV}_stage AS final
ARG user
ARG group
ARG home
RUN chown -R $user:$group $APP_PATH
USER $user
WORKDIR $home