feat: Implement a new layered architecture for the QR generator, integrating Axum, Maud, and HTMX, and updating documentation.

This commit is contained in:
2025-12-30 03:28:03 +01:00
parent 286e10160f
commit 9f12d44489
25 changed files with 2713 additions and 536 deletions

View File

@@ -1,23 +1,40 @@
FROM rust:1 AS chef
# We only pay the installation cost once,
# it will be cached from the second build onwards
FROM rust:1-slim AS chef
RUN cargo install cargo-chef
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
# Build dependencies - this is the caching layer
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY . .
RUN cargo build --release --bin qr-generator
RUN cargo build --release --bin k-qr
# We do not need the Rust toolchain to run the binary!
# Runtime stage
FROM debian:bookworm-slim AS runtime
WORKDIR /app
COPY --from=builder /app/target/release/qr-generator /usr/local/bin
ENTRYPOINT ["/usr/local/bin/qr-generator"]
# Install necessary runtime dependencies (if any, usually none for static rust binaries)
# Create a non-root user
RUN groupadd -g 10001 appgroup && \
useradd -u 10001 -g appgroup appuser
# Copy the binary from the builder stage
COPY --from=builder /app/target/release/k-qr /usr/local/bin/k-qr
# Set default environment variables
ENV SERVER_HOST=0.0.0.0
ENV SERVER_PORT=3000
ENV RUST_LOG=k_qr=info
# Use the non-root user
USER appuser
EXPOSE 3000
ENTRYPOINT ["/usr/local/bin/k-qr"]