This commit is contained in:
2026-01-12 00:53:54 +01:00
commit 2f827c168d
26 changed files with 3145 additions and 0 deletions

44
server/Dockerfile Normal file
View File

@@ -0,0 +1,44 @@
# 1. Builder Stage
FROM rust:1.92 AS builder
WORKDIR /app
# --- OPTIMIZATION: Dependency Caching ---
# 1. Create a dummy project to cache dependencies
RUN mkdir src
RUN echo "fn main() {}" > src/main.rs
# 2. Copy manifests
COPY Cargo.toml Cargo.lock ./
# 3. Build only dependencies (this layer is cached until Cargo.toml changes)
RUN cargo build --release
# 4. Now remove dummy source and copy your actual source
# We 'touch' main.rs to ensure Cargo realizes it needs a rebuild
RUN rm -rf src
COPY . .
RUN touch src/main.rs
# 5. Build the actual application
RUN cargo build --release
# 2. Runtime Stage
FROM debian:bookworm-slim
WORKDIR /app
# Install OpenSSL & CA Certificates
RUN apt-get update && \
apt-get install -y libssl3 ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Copy the binary from builder
# Note: Ensure the binary name matches 'package.name' in Cargo.toml ("server")
COPY --from=builder /app/target/release/server .
# Documentation for ports
EXPOSE 3000
# Run the binary
CMD ["./server"]