-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
55 lines (43 loc) · 1.16 KB
/
Dockerfile
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
46
47
48
49
50
51
52
53
54
55
# Build stage
FROM rust:1.75-slim-bookworm as builder
WORKDIR /usr/src/app
RUN apt-get update && apt-get install -y \
pkg-config \
libvirt-dev \
libnvidia-ml-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Cache dependencies
RUN cargo install cargo-chef
COPY Cargo.toml Cargo.lock ./
RUN cargo chef prepare --recipe-path recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Copy source code
COPY . ./
# Build application
RUN cargo build --release --locked
# Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
libvirt0 \
libnvidia-ml1 \
libvirt-clients \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -ms /bin/bash appuser
WORKDIR /app
RUN chown appuser:appuser /app
USER appuser
# Copy the built executable
COPY --from=builder /usr/src/app/target/release/gpu-share-vm-manager .
# Copy configuration
COPY config /app/config
# Create necessary directories
RUN mkdir -p /var/lib/gpu-share/images
# Set environment variables
ENV CONFIG_PATH=/app/config
ENV RUST_LOG=info
EXPOSE 3000
ENTRYPOINT ["./gpu-share-vm-manager"]
CMD ["serve"]