You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB
Docker

FROM rust:1-slim AS builder
RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy workspace files
COPY Cargo.toml Cargo.lock ./
COPY crates/knowfoolery-shared/Cargo.toml crates/knowfoolery-shared/Cargo.toml
COPY crates/knowfoolery-server/Cargo.toml crates/knowfoolery-server/Cargo.toml
# Create stub files for dependency caching
RUN mkdir -p crates/knowfoolery-shared/src && echo "pub fn stub() {}" > crates/knowfoolery-shared/src/lib.rs
RUN mkdir -p crates/knowfoolery-server/src && echo "fn main() {}" > crates/knowfoolery-server/src/main.rs
RUN mkdir -p crates/knowfoolery-server/migrations && touch crates/knowfoolery-server/migrations/.keep
# Build dependencies only
RUN cargo build --release 2>/dev/null || true
# Copy real source
COPY crates/ crates/
# Touch to invalidate cache
RUN touch crates/knowfoolery-shared/src/lib.rs crates/knowfoolery-server/src/main.rs
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/knowfoolery-server /usr/local/bin/
EXPOSE 3000
CMD ["knowfoolery-server"]