Files
chatapp/backend/Dockerfile
T
zxq5 529d09aabc frontend v0.4.1
- fixed most of the bugs with the rewrite. should be ready to deploy now
2026-04-08 00:00:28 +01:00

45 lines
1.2 KiB
Docker

FROM docker.io/rust:1-slim-bookworm AS build
## cargo package name: customize here or provide via --build-arg
ARG pkg=backend
ARG DATABASE_URL
WORKDIR /build
# we don't want to copy this for now as we're using unstable settings for faster debug builds!
# COPY .cargo .cargo
COPY cdn cdn
COPY src src
COPY Cargo.toml Cargo.toml
COPY Rocket.toml Rocket.toml
RUN apt-get update && apt-get install -y libssl-dev pkg-config
RUN --mount=type=cache,target=/build/target \
--mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
set -eux; \
cargo build --release; \
objcopy --compress-debug-sections target/release/$pkg ./main
################################################################################
FROM docker.io/debian:bookworm-slim
RUN apt-get update && apt-get install -y libssl-dev pkg-config
WORKDIR /app
## copy the main binary
COPY --from=build /build/main ./
## copy runtime assets which may or may not exist
COPY --from=build /build/Rocket.toml ./Rocket.toml
COPY --from=build /build/cdn ./cdn
## ensure the container listens globally on port 8000
ENV ROCKET_ADDRESS=0.0.0.0
ENV ROCKET_PORT=8000
CMD ./main