-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (39 loc) · 1.27 KB
/
Dockerfile
File metadata and controls
53 lines (39 loc) · 1.27 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
48
49
50
51
52
53
# Use multi-stage build for smaller final image
FROM rust:1.75-slim as builder
WORKDIR /app
# Install system 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 ./
COPY ghost-core/Cargo.toml ghost-core/
COPY ghost-cli/Cargo.toml ghost-cli/
# Create dummy source files to build dependencies
RUN mkdir ghost-core/src ghost-cli/src && \
echo "fn main() {}" > ghost-cli/src/main.rs && \
echo "" > ghost-core/src/lib.rs
# Build dependencies
RUN cargo build --release && \
rm -rf ghost-core/src ghost-cli/src target/release/deps/ghost*
# Copy source code
COPY ghost-core/src ghost-core/src/
COPY ghost-cli/src ghost-cli/src/
# Build application
RUN cargo build --release --bin ghost-cli
# Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -r -s /bin/false ghost
# Copy binary
COPY --from=builder /app/target/release/ghost-cli /usr/local/bin/ghost
# Set ownership and permissions
RUN chown root:root /usr/local/bin/ghost && \
chmod 755 /usr/local/bin/ghost
USER ghost
ENTRYPOINT ["/usr/local/bin/ghost"]