From b9763c44ccbada7f9271519c02b73108f1b46409 Mon Sep 17 00:00:00 2001 From: dev Date: Mon, 12 Oct 2026 23:58:34 +0530 Subject: [PATCH] Add multi-stage Dockerfile (17MB binary, SQLite volume, healthcheck) rust:1.99-slim build, debian-slim runtime as uid 10001. Only static/ and content/ shipped alongside the binary; DB lives on /data volume. Could not build-verify locally (no Docker daemon); paths checked against ServeDir/include_str usage instead. --- deploy/Dockerfile | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 deploy/Dockerfile diff --git a/deploy/Dockerfile b/deploy/Dockerfile new file mode 100644 index 0000000..56c7152 --- /dev/null +++ b/deploy/Dockerfile @@ -0,0 +1,30 @@ +# WhalePrep — single static binary + SQLite file, no other services. +# Build: docker build -f deploy/Dockerfile -t whaleprep . +# Run: docker run -p 8080:8080 -v whaleprep-data:/data \ +# -e PYQ_DB=/data/whaleprep.db whaleprep +# Google: add -e GOOGLE_CLIENT_ID=... -e GOOGLE_CLIENT_SECRET=... +FROM rust:1.99-slim-bookworm AS build +RUN apt-get update && apt-get install -y --no-install-recommends \ + pkg-config libsqlite3-dev && rm -rf /var/lib/apt/lists/* +WORKDIR /app +COPY Cargo.toml Cargo.lock ./ +COPY src ./src +COPY static ./static +COPY content ./content +RUN cargo build --release + +FROM debian:bookworm-slim +RUN apt-get update && apt-get install -y --no-install-recommends \ + libsqlite3-0 ca-certificates curl && rm -rf /var/lib/apt/lists/* \ + && useradd -m -u 10001 app +USER app +WORKDIR /app +COPY --from=build /app/target/release/whaleprep ./whaleprep +COPY --from=build /app/static ./static +COPY --from=build /app/content ./content +VOLUME /data +ENV PYQ_DB=/data/whaleprep.db PYQ_ADDR=0.0.0.0:8080 RUST_LOG=info +EXPOSE 8080 +HEALTHCHECK --interval=30s --timeout=5s --start-period=10s \ + CMD curl -fsS http://127.0.0.1:8080/ || exit 1 +CMD ["./whaleprep"]