-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile.cli
More file actions
47 lines (33 loc) · 1.15 KB
/
Dockerfile.cli
File metadata and controls
47 lines (33 loc) · 1.15 KB
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
# === Stage 1: Build the CLI application ===
FROM rust:1.85 AS builder
# Set the working directory to the workspace root
WORKDIR /usr/src/app
# Copy the entire workspace source code
COPY . .
# Pre-fetch dependencies (improves caching)
RUN cargo fetch
# Build only the CLI package in release mode
RUN cargo build --release -p cli
# === Stage 2: Create a minimal runtime image ===
FROM debian:bookworm-slim
# Install CA certificates for HTTPS requests and other minimal dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user for security
RUN useradd -m -u 1000 cliuser
# Set working directory (this will be the mount point)
WORKDIR /app
# Copy the compiled CLI binary from the builder stage
COPY --from=builder /usr/src/app/target/release/invok /usr/local/bin/invok
# Ensure the binary is executable
RUN chmod +x /usr/local/bin/invok
# Switch to non-root user
USER cliuser
# Set environment variable to indicate Docker environment
ENV ENV=DOCKER
# Set the entrypoint to the invok binary
ENTRYPOINT ["invok"]
# Default command (show help if no args provided)
CMD ["--help"]