|
1 | | -FROM ghcr.io/prefix-dev/pixi:0.72.0-noble |
| 1 | +FROM ghcr.io/prefix-dev/pixi:0.72.2-noble AS build |
| 2 | + |
| 3 | +# ARGS |
| 4 | +ARG LANGUAGE="en_US" |
| 5 | +ARG ENCODING="UTF-8" |
| 6 | + |
| 7 | +ENV LOCALE_STR="${LANGUAGE}.${ENCODING} ${ENCODING}" \ |
| 8 | + DEBIAN_FRONTEND=noninteractive |
| 9 | + |
| 10 | +# Install and Configure default locale |
| 11 | +# NB GHC has its own language handlling via Babel. |
| 12 | +RUN apt update -y \ |
| 13 | + && apt install -y locales \ |
| 14 | + && echo "${LOCALE_STR}" > /etc/locale.gen \ |
| 15 | + && locale-gen \ |
| 16 | + && rm -rf /var/lib/apt/lists/* |
| 17 | + |
| 18 | +WORKDIR /app |
| 19 | +COPY . . |
| 20 | + |
| 21 | +RUN pixi install -e prod --locked |
| 22 | +RUN echo '#!/bin/bash' > /app/pixi-env.sh |
| 23 | +RUN pixi shell-hook -e prod -s bash --as-is >> /app/pixi-env.sh |
| 24 | +RUN echo 'exec "$@"' >> /app/pixi-env.sh |
| 25 | +RUN echo chmod +x /app/pixi-env.sh |
| 26 | +RUN pixi run -e prod setup |
| 27 | +RUN cp docker/config_site.py instance/ |
| 28 | +RUN if [ -d docker/plugins ]; then cp -ar docker/plugins/* /app/GeoHealthCheck/plugins/; fi |
| 29 | + |
| 30 | +# Slim down, removing unused files generated within build |
| 31 | +RUN rm -rf /app/GeoHealthCheck/docs |
| 32 | +RUN find /app/GeoHealthCheck/static/lib -type d -name docs | xargs rm -rf |
| 33 | +RUN find /app/GeoHealthCheck/static/lib -type d -name src | xargs rm -rf |
| 34 | + |
| 35 | +FROM ubuntu:24.04 AS production |
2 | 36 |
|
3 | 37 | # Credits to yjacolin for providing first versions |
4 | 38 | LABEL original_developer="yjacolin <yves.jacolin@camptocamp.com>" \ |
5 | 39 | maintainer="Just van den Broecke <justb4@gmail.com>" |
6 | 40 |
|
| 41 | +# Copy the compiled locale files from the builder |
| 42 | +COPY --from=build /usr/lib/locale/locale-archive /usr/lib/locale/locale-archive |
| 43 | +COPY --from=build /etc/locale.gen /etc/locale.gen |
| 44 | +COPY --from=build /etc/default/locale /etc/default/locale |
| 45 | + |
7 | 46 | # These are default values, |
8 | 47 | # Override when running container via docker(-compose) |
9 | 48 |
|
10 | | -# ARGS |
11 | | -ARG TZ="Etc/UTC" |
12 | | -ARG LANG="en_US.UTF-8" |
13 | | -ARG ADD_DEB_PACKAGES="" |
14 | | - |
15 | 49 | # General ENV settings |
16 | | -ENV LC_ALL="en_US.UTF-8" \ |
17 | | - LANG="en_US.UTF-8" \ |
18 | | - LANGUAGE="en_US.UTF-8" \ |
19 | | - \ |
20 | | - \ |
21 | | - DEB_PACKAGES="ca-certificates locales postgresql-client" \ |
22 | | - DEB_BUILD_DEPS="curl adduser" \ |
| 50 | +ENV LANG='en_US.UTF-8' \ |
| 51 | + LANGUAGE='en_US:en' \ |
| 52 | + LC_ALL='en_US.UTF-8' \ |
| 53 | + TZ='Etc/UTC' \ |
| 54 | + DEB_PACKAGES="ca-certificates postgresql-client" \ |
| 55 | + DEB_BUILD_DEPS="adduser" \ |
23 | 56 | ADMIN_NAME=admin \ |
24 | 57 | ADMIN_PWD=admin \ |
25 | 58 | ADMIN_EMAIL=admin.istrator@mydomain.com \ |
26 | | - SQLALCHEMY_DATABASE_URI='sqlite:////GeoHealthCheck/DB/data.db' \ |
| 59 | + SQLALCHEMY_DATABASE_URI='sqlite:////app/instance/DB/data.db' \ |
27 | 60 | SQLALCHEMY_ENGINE_OPTION_PRE_PING=False \ |
28 | 61 | SECRET_KEY='d544ccc37dc3ad214c09b1b7faaa64c60351d5c8bb48b342' \ |
29 | | - GHC_HOME=/GeoHealthCheck \ |
| 62 | + GHC_HOME=/app \ |
| 63 | + GHC_USER=ghc \ |
| 64 | + GHC_USER_HOME=/home/ghc \ |
30 | 65 | GHC_PROBE_HTTP_TIMEOUT_SECS=30 \ |
31 | 66 | GHC_MINIMAL_RUN_FREQUENCY_MINS=10 \ |
32 | 67 | GHC_RETENTION_DAYS=30 \ |
@@ -55,57 +90,39 @@ ENV LC_ALL="en_US.UTF-8" \ |
55 | 90 | GHC_GEOIP_LATFIELD='lat' \ |
56 | 91 | GHC_GEOIP_LONFIELD='lon' \ |
57 | 92 | GHC_METADATA_CACHE_SECS=900 \ |
58 | | - \ |
59 | | -# WSGI server settings, assumed is gunicorn \ |
60 | | -HOST=0.0.0.0 \ |
61 | | -PORT=80 \ |
62 | | -WSGI_WORKERS=4 \ |
63 | | -WSGI_WORKER_TIMEOUT=6000 \ |
64 | | -WSGI_WORKER_CLASS='gevent' \ |
65 | | -\ |
| 93 | + HOST=0.0.0.0 \ |
| 94 | + PORT=80 \ |
| 95 | + WSGI_WORKERS=4 \ |
| 96 | + WSGI_WORKER_TIMEOUT=6000 \ |
| 97 | + WSGI_WORKER_CLASS='gevent' \ |
| 98 | + GHC_USER_PLUGINS='' |
| 99 | + |
66 | 100 | # GHC Core Plugins modules and/or classes, seldom needed to set: \ |
67 | 101 | # if not specified here or in Container environment \ |
68 | 102 | # all GHC built-in Plugins will be active. \ |
69 | 103 | #ENV GHC_PLUGINS 'GeoHealthCheck.plugins.probe.owsgetcaps,\ |
70 | 104 | # GeoHealthCheck.plugins.probe.wms, ...., ...\ |
71 | 105 | # GeoHealthCheck.plugins.check.checks' \ |
72 | | -\ |
73 | | -# GHC User Plugins, best be overridden via Container environment \ |
74 | | -GHC_USER_PLUGINS='' |
75 | | - |
76 | | -# Add standard files and Add/override Plugins |
77 | | -# Alternative Entrypoints to run GHC jobs |
78 | | -# Override default Entrypoint with these on Containers |
79 | | -COPY docker/scripts/*.sh docker/config_site.py docker/plugins / |
80 | 106 |
|
81 | | -# Add Source Code |
82 | | -COPY . ${GHC_HOME} |
83 | | - |
84 | | -WORKDIR ${GHC_HOME} |
| 107 | +# GHC User Plugins, best be overridden via Container environment \ |
85 | 108 |
|
86 | 109 | # Install operating system dependencies |
87 | 110 | RUN \ |
88 | | - apt-get update \ |
89 | | - && apt-get --no-install-recommends install -y ${DEB_PACKAGES} ${DEB_BUILD_DEPS} ${ADD_DEB_PACKAGES} \ |
90 | | - && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \ |
| 111 | + apt update \ |
| 112 | + && apt --no-install-recommends install -y ${DEB_PACKAGES} ${DEB_BUILD_DEPS} \ |
91 | 113 | && echo "For ${TZ} date=$(date)" && echo "Locale=$(locale)" \ |
92 | | - && adduser --disabled-password --shell /bin/bash --home ${GHC_HOME} --gecos "User" ghc \ |
93 | | - && chmod +x /*.sh \ |
94 | | - && pixi install --locked -e prod \ |
95 | | - && pixi run -e prod setup \ |
96 | | - && cp /config_site.py ${GHC_HOME}/instance/config_site.py \ |
97 | | - && if [ -d /plugins ]; then cp -ar /plugins/* ${GHC_HOME}/GeoHealthCheck/plugins/; fi && rm -rf /plugins \ |
98 | | - && apt-get remove --purge -y ${DEB_BUILD_DEPS} \ |
99 | | - && apt-get clean \ |
| 114 | + && adduser --disabled-password --shell /bin/bash --gecos "User" ${GHC_USER} \ |
| 115 | + && apt remove --purge -y ${DEB_BUILD_DEPS} \ |
| 116 | + && apt clean \ |
100 | 117 | && apt autoremove -y \ |
101 | 118 | && rm -rf /var/lib/apt/lists/* |
102 | 119 |
|
103 | | -# For later: run as user 'ghc' |
104 | | -# USER ghc |
| 120 | +WORKDIR /app |
| 121 | +COPY --from=build --chown=${GHC_USER}:${GHC_USER} /app /app |
105 | 122 |
|
106 | | -# For SQLite |
107 | | -VOLUME ["/GeoHealthCheck/DB/"] |
| 123 | +# For later: run as user 'ghc' |
| 124 | +USER ${GHC_USER} |
108 | 125 |
|
109 | 126 | EXPOSE ${PORT} |
110 | 127 |
|
111 | | -ENTRYPOINT /run-web.sh |
| 128 | +ENTRYPOINT [ "/app/docker/scripts/run-web.sh" ] |
0 commit comments