rhythm-backend/Dockerfile
Dmitri ed7fff4983
Some checks are pending
Build and Push Docker Image / build-and-push (push) Waiting to run
cache
2026-05-03 22:39:22 +02:00

22 lines
554 B
Docker

FROM rust:1.95.0-alpine3.22 AS builder
WORKDIR /app
# Cache dependencies by building a dummy project first
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release
RUN rm -rf src
# Copy real source code and build
COPY . .
# Touch the main file to ensure cargo sees it as newer than the dummy build
RUN touch src/main.rs
RUN cargo build --release
# Small runtime image
FROM alpine:3.22
WORKDIR /app
COPY --from=builder /app/target/release/rhythm-backend /app/executable
ENTRYPOINT ["/app/executable"]