Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions servers/rust-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*

RUN cargo install cargo-chef --version ^0.1

RUN cargo install sccache --version ^0.7

ENV RUSTC_WRAPPER=sccache SCCACHE_DIR=/sccache

FROM base AS planner

WORKDIR /app

COPY Cargo.toml Cargo.lock ./

COPY entity ./entity

COPY migration ./migration

COPY src ./src

RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo chef prepare --recipe-path recipe.json
Expand All @@ -25,31 +32,33 @@ FROM base AS builder
WORKDIR /build

COPY --from=planner /app/recipe.json recipe.json

RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo chef cook --release --recipe-path recipe.json

COPY Cargo.toml Cargo.lock ./

COPY templates ./templates

COPY entity ./entity

COPY migration ./migration

COPY src ./src

RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo build --release

FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
FROM gcr.io/distroless/cc-debian12:nonroot

WORKDIR /app

COPY --from=builder /build/target/release/finwar-market /app/finwar-market

COPY templates ./templates

COPY static ./static

ENV RUST_LOG=info
Expand Down