1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Build stage
FROM --platform=linux/amd64 rust:1.82-slim-bookworm as builder
# Install required dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Create a new empty shell project
WORKDIR /usr/src/app
# Copy only necessary files first
COPY Cargo.toml Cargo.lock ./
# Create a dummy main.rs to build dependencies
RUN mkdir src && \
echo "fn main() {}" > src/main.rs && \
cargo build --release --target x86_64-unknown-linux-gnu && \
rm -rf src
# Now copy the real source code
COPY src ./src
# Build the application
RUN RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-gnu && \
strip target/x86_64-unknown-linux-gnu/release/noveum-ai-gateway
# Runtime stage
FROM --platform=linux/amd64 debian:bookworm-slim
# Add LABEL to identify the image
LABEL org.opencontainers.image.source="https://github.com/noveum-ai/ai-gateway"
LABEL org.opencontainers.image.description="Noveum AI Gateway"
LABEL org.opencontainers.image.version="latest"
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*
# Copy the binary from builder
COPY --from=builder /usr/src/app/target/x86_64-unknown-linux-gnu/release/noveum-ai-gateway /usr/local/bin/
# Set the startup command
CMD ["noveum-ai-gateway"]