45 lines
1.7 KiB
Docker
45 lines
1.7 KiB
Docker
# Production image for ht_booking (Tenis Rajec).
|
|
#
|
|
# Three stages:
|
|
# css — compiles the Tailwind/daisyUI stylesheet with Node
|
|
# builder — compiles the release binary with Rust
|
|
# runtime — slim Debian image holding just the binary + assets
|
|
#
|
|
# Built and run via docker-compose.prod.yml — see DEPLOY.md.
|
|
|
|
# ---- Stage 1 — Tailwind + daisyUI stylesheet -------------------------------
|
|
FROM node:20-slim AS css
|
|
WORKDIR /build
|
|
COPY package.json package-lock.json tailwind.config.js ./
|
|
RUN npm ci
|
|
COPY assets/css ./assets/css
|
|
COPY assets/views ./assets/views
|
|
RUN mkdir -p assets/static/css && npm run build:css
|
|
|
|
# ---- Stage 2 — release binary ----------------------------------------------
|
|
# Latest stable Rust, pinned to Debian bookworm so the compiled binary's glibc
|
|
# matches the bookworm-slim runtime stage below.
|
|
FROM rust:1-slim-bookworm AS builder
|
|
WORKDIR /usr/src
|
|
COPY . .
|
|
RUN cargo build --release --bin ht_booking-cli
|
|
|
|
# ---- Stage 3 — runtime -----------------------------------------------------
|
|
FROM debian:bookworm-slim
|
|
# ca-certificates: outbound TLS. curl: the container healthcheck.
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends ca-certificates curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
WORKDIR /usr/app
|
|
COPY --from=builder /usr/src/target/release/ht_booking-cli ht_booking-cli
|
|
COPY --from=builder /usr/src/assets assets
|
|
COPY --from=builder /usr/src/config config
|
|
# Replace the committed CSS with one freshly built from the current templates,
|
|
# so the image is always self-consistent regardless of what was committed.
|
|
COPY --from=css /build/assets/static/css/app.css assets/static/css/app.css
|
|
# Selects config/production.yaml at startup.
|
|
ENV LOCO_ENV=production
|
|
EXPOSE 5150
|
|
ENTRYPOINT ["/usr/app/ht_booking-cli"]
|
|
CMD ["start"]
|