-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (35 loc) · 1014 Bytes
/
Dockerfile
File metadata and controls
48 lines (35 loc) · 1014 Bytes
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
# Build stage
FROM rust:1.88-slim-bookworm AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy project files
COPY server/Cargo.toml server/Cargo.lock ./
COPY server/src ./src
COPY static ./static
COPY content ./content
# Build release binary
RUN cargo build --release --locked
# Production stage
FROM debian:bookworm-slim AS production
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
# Copy binary and static files
COPY --from=builder /app/target/release/matrix-blog /app/
COPY --from=builder /app/static /app/static
COPY --from=builder /app/content /app/content
# Change ownership
RUN chown -R appuser:appgroup /app
USER appuser
EXPOSE 8080
CMD ["/app/matrix-blog"]