2026-01-27 16:21:58 +00:00
|
|
|
# Likwid Backend Dockerfile
|
2026-01-28 23:30:56 +00:00
|
|
|
FROM rust:1.88-slim-bookworm as builder
|
2026-01-27 16:21:58 +00:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-01-28 23:30:56 +00:00
|
|
|
ENV SQLX_OFFLINE=true
|
|
|
|
|
|
2026-01-27 16:21:58 +00:00
|
|
|
# Install build dependencies
|
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
|
|
|
pkg-config \
|
|
|
|
|
libssl-dev \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# Copy manifests
|
|
|
|
|
COPY Cargo.toml Cargo.lock ./
|
|
|
|
|
|
|
|
|
|
# Create dummy main to cache dependencies
|
|
|
|
|
RUN mkdir src && echo "fn main() {}" > src/main.rs
|
|
|
|
|
RUN cargo build --release
|
|
|
|
|
RUN rm -rf src
|
|
|
|
|
|
|
|
|
|
# Copy source code
|
|
|
|
|
COPY src ./src
|
|
|
|
|
COPY migrations ./migrations
|
2026-01-28 23:30:56 +00:00
|
|
|
COPY migrations_demo ./migrations_demo
|
|
|
|
|
COPY .sqlx ./.sqlx
|
|
|
|
|
|
|
|
|
|
# Optionally exclude demo seed migration from the compiled binary (enterprise-safe prod builds)
|
|
|
|
|
ARG INCLUDE_DEMO_SEED=false
|
|
|
|
|
RUN if [ "$INCLUDE_DEMO_SEED" != "true" ]; then rm -f ./migrations_demo/20260127150000_demo_seed_data.sql; fi
|
2026-01-27 16:21:58 +00:00
|
|
|
|
|
|
|
|
# Build the actual binary
|
|
|
|
|
RUN touch src/main.rs && cargo build --release
|
|
|
|
|
|
|
|
|
|
# Runtime stage
|
|
|
|
|
FROM debian:bookworm-slim
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Install runtime dependencies
|
|
|
|
|
RUN apt-get update && apt-get install -y \
|
|
|
|
|
ca-certificates \
|
|
|
|
|
libssl3 \
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
# Copy binary and migrations
|
|
|
|
|
COPY --from=builder /app/target/release/likwid /app/likwid
|
|
|
|
|
COPY --from=builder /app/migrations /app/migrations
|
|
|
|
|
|
|
|
|
|
# Create non-root user
|
|
|
|
|
RUN useradd -r -s /bin/false likwid
|
|
|
|
|
USER likwid
|
|
|
|
|
|
|
|
|
|
EXPOSE 3000
|
|
|
|
|
|
|
|
|
|
CMD ["./likwid"]
|