hezarfen_backend
Clone
https://git.tahinli.com/archive/hezarfen_backend.git
0 watching0 forksRust8.3 MiB08aa13eAhmet Kaan Gümüş2 months ago378 commits
| 1 | # Build stage. Edition 2024 needs Rust >= 1.85; pinned to the current stable. |
| 2 | FROM docker.io/library/rust:1.97-slim AS builder |
| 3 | |
| 4 | # utoipa-swagger-ui's build script downloads the Swagger UI bundle with curl. |
| 5 | RUN apt-get update && \ |
| 6 | apt-get install -y --no-install-recommends curl ca-certificates && \ |
| 7 | rm -rf /var/lib/apt/lists/* |
| 8 | |
| 9 | WORKDIR /app |
| 10 | COPY Cargo.toml Cargo.lock ./ |
| 11 | COPY 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. |
| 16 | RUN --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. |
| 22 | FROM docker.io/library/debian:trixie-slim |
| 23 | |
| 24 | RUN 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 | |
| 30 | COPY --from=builder /usr/local/bin/hezarfen_backend /usr/local/bin/hezarfen_backend |
| 31 | |
| 32 | USER 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. |
| 36 | ENV HOST=0.0.0.0 \ |
| 37 | PORT=8080 \ |
| 38 | DB_URL=ws://surrealdb:8000 |
| 39 | |
| 40 | EXPOSE 8080 |
| 41 | |
| 42 | ENTRYPOINT ["/usr/local/bin/hezarfen_backend"] |