-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.production
More file actions
71 lines (55 loc) · 1.8 KB
/
Dockerfile.production
File metadata and controls
71 lines (55 loc) · 1.8 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Multi-stage build for minimal production image
FROM node:22-slim as ui-builder
WORKDIR /web_ui
COPY web_ui/package*.json ./
RUN npm install
COPY web_ui .
RUN npm run build
FROM rust:1.93-slim as builder
WORKDIR /build
# Install dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
findutils \
&& rm -rf /var/lib/apt/lists/*
# Copy manifests
COPY Cargo.toml Cargo.lock ./
# Copy source
COPY src ./src
COPY build.rs ./
COPY data ./data
COPY --from=ui-builder /web_ui/dist ./web_ui/dist
# Build release binary (with UI feature enabled)
RUN cargo build --release --features ui
# Find the tokenizer binary (it's hidden in target/release/build/...)
RUN find target -name "en_tokenizer.bin" -type f -exec cp {} /build/en_tokenizer.bin \;
# Production image
FROM debian:bookworm-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy binary from builder
COPY --from=builder /build/target/release/cuemap /app/cuemap
# Copy tokenizer and assets to ASSETS directory (separate from data volume)
COPY --from=builder /build/en_tokenizer.bin /app/assets/en_tokenizer.bin
COPY data /app/assets
# Create data directory (for volume) and assets directory
RUN mkdir -p /app/data /app/assets/public
# Expose port
EXPOSE 8080
# Set environment variables
ENV RUST_LOG=info
ENV PORT=8080
ENV DATA_DIR=/app/data
ENV ASSETS_DIR=/app/assets
ENV TOKENIZER_PATH=/app/assets/en_tokenizer.bin
ENV SNAPSHOT_INTERVAL=60
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/ || exit 1
# Run the binary
CMD ["/app/cuemap", "--port", "8080", "--data-dir", "/app/data", "--assets-dir", "/app/assets", "--snapshot-interval", "60"]