perfect-postcode/Dockerfile
Andras Schmelczer c2c4ed6708
Some checks failed
Build and publish Docker image / build-and-push (push) Successful in 5m38s
CI / Check (push) Failing after 29m8s
better
2026-06-22 23:00:43 +01:00

59 lines
3.1 KiB
Docker

# Stage 1: Build frontend
FROM node:22-bookworm-slim AS frontend
WORKDIR /app/frontend
ARG FRONTEND_BUGSINK_DSN=
ARG BUGSINK_ENVIRONMENT=production
ARG BUGSINK_RELEASE=
ARG BUGSINK_SEND_DEFAULT_PII=true
ENV FRONTEND_BUGSINK_DSN=$FRONTEND_BUGSINK_DSN
ENV BUGSINK_ENVIRONMENT=$BUGSINK_ENVIRONMENT
ENV BUGSINK_RELEASE=$BUGSINK_RELEASE
ENV BUGSINK_SEND_DEFAULT_PII=$BUGSINK_SEND_DEFAULT_PII
# Puppeteer's bundled Chrome downloads from storage.googleapis.com, which is
# geo-blocked on the CI host ("this service is not available in your location").
# Install Chromium from Debian instead: it's reachable, currently tracks the same
# Chrome 149.x puppeteer expects, and apt pulls in the system libraries it needs.
# So: skip puppeteer's postinstall browser download and point its launcher (used
# by the prerender step) at the system binary.
ENV PUPPETEER_SKIP_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
RUN apt-get update \
&& apt-get install -y --no-install-recommends chromium \
&& rm -rf /var/lib/apt/lists/*
COPY frontend/ ./
RUN npm run build
# Stage 2: Build Rust server
FROM rust:1.84-bookworm AS server
WORKDIR /app
COPY server-rs/ server-rs/
WORKDIR /app/server-rs
RUN cargo build --release
# Stage 3: Runtime
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl && rm -rf /var/lib/apt/lists/*
RUN groupadd -r appuser && useradd -r -g appuser -d /app appuser
WORKDIR /app
COPY --from=server /app/server-rs/target/release/property-map-server ./
COPY --from=frontend /app/frontend/dist ./frontend/dist/
VOLUME ["/app/data"]
RUN chown -R appuser:appuser /app
USER appuser
# Fallback for any allocations not served by jemalloc (the binary's global
# allocator, tuned via the baked-in malloc_conf): cap glibc to 2 arenas so freed
# memory coalesces and is returned instead of fragmenting across per-CPU arenas.
ENV MALLOC_ARENA_MAX=2
EXPOSE 8001
HEALTHCHECK --interval=30s --timeout=5s --start-period=120s --retries=3 \
CMD curl -f http://localhost:8001/health || exit 1
ENTRYPOINT ["./property-map-server"]
CMD ["--properties", "/app/data/properties.parquet", "--postcode-features", "/app/data/postcode.parquet", "--pois", "/app/data/filtered_uk_pois.parquet", "--places", "/app/data/places.parquet", "--tiles", "/app/data/uk.pmtiles", "--postcodes", "/app/data/postcode_boundaries", "--travel-times", "/app/data/travel-times", "--satellite-tiles", "/app/data/satellite.pmtiles", "--satellite-highres-tiles", "/app/data/satellite_highres.pmtiles", "--noise-overlay-tiles", "/app/data/noise_lden_10m.pmtiles", "--crime-hotspot-tiles", "/app/data/crime_hotspots.pmtiles", "--tree-overlay-tiles", "/app/data/trees_outside_woodlands.pmtiles", "--property-border-tiles", "/app/data/property_borders.pmtiles", "--crime-by-year-path", "/app/data/crime_by_postcode_by_year.parquet", "--area-crime-averages-path", "/app/data/area_crime_averages.parquet", "--population-path", "/app/data/population_by_postcode.parquet", "--developments-path", "/app/data/development_sites.parquet", "--dist", "/app/frontend/dist"]