-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
97 lines (78 loc) · 2.47 KB
/
Dockerfile
File metadata and controls
97 lines (78 loc) · 2.47 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# * [EDD-8] Titan-Flow Production Dockerfile
# * Multi-stage build for optimized container size
# =============================================================================
# Stage 1: Build Stage
# =============================================================================
FROM rust:1.75-bookworm AS builder
# * Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*
# * Create app directory
WORKDIR /app
# * Copy manifests first for better caching
COPY Cargo.toml Cargo.lock ./
# * Create dummy source to build dependencies
RUN mkdir src && \
echo "fn main() {}" > src/main.rs && \
mkdir -p src/bin && \
echo "fn main() {}" > src/bin/main.rs
# * Build dependencies only (cached layer)
RUN cargo build --release && rm -rf src
# * Copy actual source code
COPY src ./src
COPY tests ./tests
# * Build the application
RUN touch src/lib.rs src/bin/main.rs && \
cargo build --release --bin main
# =============================================================================
# Stage 2: Runtime Stage
# =============================================================================
FROM debian:bookworm-slim AS runtime
# * Install runtime dependencies for Chromium headless
RUN apt-get update && apt-get install -y --no-install-recommends \
# * Chromium browser
chromium \
# * Required libraries for Chromium
libnss3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libdrm2 \
libxkbcommon0 \
libxcomposite1 \
libxdamage1 \
libxfixes3 \
libxrandr2 \
libgbm1 \
libasound2 \
libpango-1.0-0 \
libcairo2 \
# * TLS support
ca-certificates \
# * Networking utilities
curl \
&& rm -rf /var/lib/apt/lists/*
# * Create non-root user for security
RUN useradd -m -u 1000 -s /bin/bash titan
# * Set working directory
WORKDIR /app
# * Copy binary from builder
COPY --from=builder /app/target/release/main /app/titan-flow
# * Set proper permissions
RUN chown -R titan:titan /app
# * Switch to non-root user
USER titan
# * Expose metrics port
EXPOSE 9000
# * Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:9000/health || exit 1
# * Set environment variables
ENV RUST_LOG=info
ENV CHROME_BIN=/usr/bin/chromium
ENV CHROME_FLAGS="--no-sandbox --disable-dev-shm-usage --disable-gpu --headless"
# * Run the application
ENTRYPOINT ["/app/titan-flow"]