Add docker build, rewrite Actions for Gitea, and add healthcheck endpoint.

This commit is contained in:
Ganonmaster
2026-04-09 17:26:35 +02:00
parent 0fd023c9fd
commit 0fd68327cd
7 changed files with 219 additions and 51 deletions
+37
View File
@@ -0,0 +1,37 @@
# ── Build stage ──────────────────────────────────────────────────────────────
FROM rust:1-slim AS builder
WORKDIR /build
# Cache dependency compilation separately from application code.
COPY Cargo.toml Cargo.lock build.rs ./
# Dummy source so `cargo build` can compile dependencies without the real code.
RUN mkdir src && echo 'fn main(){}' > src/main.rs \
&& cargo build --release \
&& rm src/main.rs
# Build the real application.
COPY src ./src
COPY migrations ./migrations
# Touch main.rs so Cargo detects the change and recompiles.
RUN touch src/main.rs \
&& cargo build --release
# ── Runtime stage ─────────────────────────────────────────────────────────────
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /build/target/release/mikebase ./mikebase
COPY migrations ./migrations
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1
ENTRYPOINT ["./mikebase"]