Website container: own the mounted data/, run as an unprivileged user; health start period
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
265d9d794b
commit
18515fb287
2 changed files with 10 additions and 4 deletions
|
|
@ -15,10 +15,10 @@ COPY --from=build /src/target/release/chesspenguin-site /usr/local/bin/
|
|||
COPY site ./site
|
||||
COPY static ./static
|
||||
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN mkdir -p /app/data && chown site /app/data
|
||||
USER site
|
||||
RUN mkdir -p /app/data
|
||||
# Starts as root only to take ownership of the mounted data/, then runs as "site".
|
||||
ENV PORT=8080 STATIC_DIR=/app/static SITE_DIR=/app/site DB_PATH=/app/data/downloads.sqlite \
|
||||
GEOIP_DB=/app/data/dbip-city-ipv4.mmdb,/app/data/dbip-city-ipv6.mmdb
|
||||
EXPOSE 8080
|
||||
HEALTHCHECK --interval=60s --timeout=5s CMD curl -fsS http://127.0.0.1:8080/healthz || exit 1
|
||||
HEALTHCHECK --interval=60s --timeout=5s --start-period=10m CMD curl -fsS http://127.0.0.1:8080/healthz || exit 1
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
#!/bin/sh
|
||||
# Fetches the DB-IP Lite City geolocation databases (CC BY 4.0, MaxMind DB format, via the
|
||||
# ip-location-db package on unpkg) when they are missing or older than 35 days, then
|
||||
# starts the server. Without them the site works and downloads are stored without a country.
|
||||
# starts the server as the unprivileged user "site". Without them the site works and
|
||||
# downloads are stored without a country.
|
||||
set -u
|
||||
# A bind-mounted ./data is created by Docker as root: hand it to "site".
|
||||
if [ "$(id -u)" = 0 ]; then
|
||||
chown -R site /app/data
|
||||
exec setpriv --reuid=site --regid=site --init-groups "$0" "$@"
|
||||
fi
|
||||
base="${GEOIP_URL:-https://unpkg.com/@ip-location-db/dbip-city-mmdb}"
|
||||
for v in ipv4 ipv6; do
|
||||
f="/app/data/dbip-city-${v}.mmdb"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue