# Static site for 200feet.net. nginx serves web/ with gzip + sane cache headers.
# Build the contents of web/ first via:
#   .venv/bin/python scripts/analyze.py
#   .venv/bin/python scripts/compare_setbacks.py
#   .venv/bin/python scripts/build_web.py
# Then:
#   docker build -t registry.davidadams.rocks/200feet:latest .
#   docker push registry.davidadams.rocks/200feet:latest

FROM nginx:1.27-alpine

# Update packages to patch vulnerabilities
RUN apk update && apk upgrade && rm -rf /var/cache/apk/*

# Drop nginx's default site
RUN rm -f /etc/nginx/conf.d/default.conf

COPY docker/nginx.conf /etc/nginx/conf.d/200feet.conf
COPY web/ /usr/share/nginx/html/

# nginx runs as 'nginx' user (uid 101) by default in the alpine image.
# /var/cache/nginx and /var/run are writable for that user already.

EXPOSE 80

HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD wget -qO- http://127.0.0.1/healthz || exit 1

CMD ["nginx", "-g", "daemon off;"]
