11FROM ghcr.io/prefix-dev/pixi:0.72.2-noble AS build
2+ # Inspired by https://tech.quantco.com/blog/pixi-production/
23
34# ARGS
45ARG LANGUAGE="en_US"
@@ -8,21 +9,27 @@ ENV LOCALE_STR="${LANGUAGE}.${ENCODING} ${ENCODING}" \
89 DEBIAN_FRONTEND=noninteractive
910
1011# Install and Configure default locale
11- # NB GHC has its own language handlling via Babel.
12+ # NB GHC has its own language handling via Babel.
1213RUN apt update -y \
1314 && apt install -y locales \
1415 && echo "${LOCALE_STR}" > /etc/locale.gen \
1516 && locale-gen \
1617 && rm -rf /var/lib/apt/lists/*
1718
19+ # Copy entire GHC repo content to /app
1820WORKDIR /app
1921COPY . .
2022
23+ # Install deps (in /app/.pixi/).
2124RUN pixi install -e prod --locked
25+
26+ # pixi-env.sh: to be sourced, sets all paths and more.
2227RUN echo '#!/bin/bash' > /app/pixi-env.sh
2328RUN pixi shell-hook -e prod -s bash --as-is >> /app/pixi-env.sh
2429RUN echo 'exec "$@"' >> /app/pixi-env.sh
2530RUN echo chmod +x /app/pixi-env.sh
31+
32+ # Prepare the GHC app, mainly web-related.
2633RUN pixi run -e prod setup
2734RUN cp docker/config_site.py instance/
2835RUN if [ -d docker/plugins ]; then cp -ar docker/plugins/* /app/GeoHealthCheck/plugins/; fi
@@ -45,8 +52,6 @@ COPY --from=build /etc/default/locale /etc/default/locale
4552
4653# These are default values,
4754# Override when running container via docker(-compose)
48-
49- # General ENV settings
5055ENV LANG='en_US.UTF-8' \
5156 LANGUAGE='en_US:en' \
5257 LC_ALL='en_US.UTF-8' \
@@ -106,7 +111,7 @@ ENV LANG='en_US.UTF-8' \
106111
107112# GHC User Plugins, best be overridden via Container environment \
108113
109- # Install operating system dependencies
114+ # Install remaining dependencies and create user.
110115RUN \
111116 apt update \
112117 && apt --no-install-recommends install -y ${DEB_PACKAGES} ${DEB_BUILD_DEPS} \
@@ -117,10 +122,11 @@ RUN \
117122 && apt autoremove -y \
118123 && rm -rf /var/lib/apt/lists/*
119124
125+ # Copy entire bundle: GHC plus all dependencies, including non-Python binaries in /app.
120126WORKDIR /app
121127COPY --from=build --chown=${GHC_USER}:${GHC_USER} /app /app
122128
123- # For later: run as user 'ghc'
129+ # Run Containers as user.
124130USER ${GHC_USER}
125131
126132EXPOSE ${PORT}
0 commit comments