Files
sorsfonalak/services/backend/Dockerfile
T
fecoandClaude Opus 5.5 ffb6060cfa
CI / test (push) Successful in 1m38s
CI / build (push) Successful in 5m46s
CI / deploy (push) Skipped
Persistent logs, no health checks in them, and softer copy
Backend and the workers also write their log as JSON into the logs
volume, one file a day kept 30 days (LOG_DIR, LOG_NAME, LOG_KEEP_DAYS),
so errors can be looked up after a container is replaced. The Docker
health check (/healthz every 30 s) no longer goes into the request log
of the backend and the horoscope API.

The home, login and packages pages no longer compare the analyses to
an experienced astrologer's depth; they say what the user gets:
detailed, personal text in minutes, for a fraction of a personal
consultation's price.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
2026-11-20 17:34:24 +00:00

34 lines
1.1 KiB
Docker

# syntax=docker/dockerfile:1
#
# Build from the repository root:
# docker build -f services/backend/Dockerfile -t sorsfonalak/backend .
ARG RUST_VERSION=1.99
# --- 1. static (musl) build ----------------------------------------------------
FROM rust:${RUST_VERSION}-alpine AS build
RUN apk add --no-cache musl-dev
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
COPY crates crates
COPY services services
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,target=/app/target,sharing=locked \
cargo build --release --locked -p backend \
&& cp target/release/backend /backend
# The log directory (LOG_DIR); a volume mounted here takes over its owner.
RUN mkdir /logs
# --- 2. runtime: the binary only (TLS roots are compiled in via webpki-roots) ---
FROM scratch
COPY --from=build /backend /backend
COPY --from=build --chown=65532:65532 /logs /logs
ENV BIND_ADDR=0.0.0.0:8081 \
LOG_FORMAT=json \
RUST_LOG=info
USER 65532:65532
EXPOSE 8081
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD ["/backend", "healthcheck"]
ENTRYPOINT ["/backend"]