forge
Explore
Log in

Don't you dare go Hollow

hezarfen_backend

Clone
★ 0

0 watching0 forksRust8.3 MiB08aa13eAhmet Kaan Gümüş2 months ago378 commits

Containerfile42 lines, 1.5 KiBHistoryRawDownload
1# Build stage. Edition 2024 needs Rust >= 1.85; pinned to the current stable.
2FROM docker.io/library/rust:1.97-slim AS builder
3
4# utoipa-swagger-ui's build script downloads the Swagger UI bundle with curl.
5RUN apt-get update && \
6 apt-get install -y --no-install-recommends curl ca-certificates && \
7 rm -rf /var/lib/apt/lists/*
8
9WORKDIR /app
10COPY Cargo.toml Cargo.lock ./
11COPY src ./src
12
13# Cache mounts keep the registry and incremental build artifacts between
14# builds. The binary must be copied out of /app/target inside the same RUN,
15# because cache mounts are not part of the image layers.
16RUN --mount=type=cache,target=/usr/local/cargo/registry \
17 --mount=type=cache,target=/app/target \
18 cargo build --release --locked && \
19 cp target/release/hezarfen_backend /usr/local/bin/hezarfen_backend
20
21# Runtime stage. curl is included for the compose healthcheck.
22FROM docker.io/library/debian:trixie-slim
23
24RUN apt-get update && \
25 apt-get install -y --no-install-recommends curl ca-certificates && \
26 rm -rf /var/lib/apt/lists/* && \
27 useradd --system --uid 10001 hezarfen && \
28 mkdir /data && chown hezarfen:hezarfen /data
29
30COPY --from=builder /usr/local/bin/hezarfen_backend /usr/local/bin/hezarfen_backend
31
32USER hezarfen
33
34# HOST must be 0.0.0.0 so the port mapping can reach the listener. DB_URL
35# points at the SurrealDB server (the compose service); /data holds uploads.
36ENV HOST=0.0.0.0 \
37 PORT=8080 \
38 DB_URL=ws://surrealdb:8000
39
40EXPOSE 8080
41
42ENTRYPOINT ["/usr/local/bin/hezarfen_backend"]