-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (36 loc) · 1.15 KB
/
Dockerfile
File metadata and controls
52 lines (36 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
48
49
50
51
52
# Multi-stage Dockerfile for MD-Book
# This Dockerfile can be used with Fly.io, Railway, or any container platform
# Build stage
FROM rust:1.70 AS builder
WORKDIR /app
# Copy manifest files
COPY Cargo.toml Cargo.lock ./
# Copy source code
COPY src ./src
COPY benches ./benches
COPY tests ./tests
# Build the application
RUN cargo build --release
# Runtime stage
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the binary from builder
COPY --from=builder /app/target/release/md-book /usr/local/bin/md-book
# Copy templates and static assets
COPY src/templates ./templates
# Copy test input for demo
COPY test_book_mdbook ./test_book_mdbook
# Create output directory
RUN mkdir -p dist
# Build site at container startup
RUN md-book -i test_book_mdbook -o dist
# Expose port (configurable via PORT env var)
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${PORT:-8080}/ || exit 1
# Start the server
CMD ["sh", "-c", "md-book -i test_book_mdbook -o dist --serve --port ${PORT:-8080}"]