-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
74 lines (56 loc) · 1.96 KB
/
Dockerfile
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
# Build stage
FROM rust:1.83-slim-bookworm as builder
WORKDIR /usr/src/iggy-bench-dashboard
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config \
libssl-dev \
openssl \
curl \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install cargo-binstall
RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
# Install trunk via cargo-binstall
RUN cargo binstall -y trunk
# Add wasm target
RUN rustup target add wasm32-unknown-unknown
# Copy the entire workspace
COPY . .
# Build frontend
RUN cd frontend && trunk build --release
# Build the server with release profile
RUN cargo build --release --package iggy-bench-dashboard-server
# Runtime stage
FROM debian:bookworm-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
openssl \
curl \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
# Copy the built binary and frontend files
COPY --from=builder /usr/src/iggy-bench-dashboard/target/release/iggy-bench-dashboard-server /app/
COPY --from=builder /usr/src/iggy-bench-dashboard/frontend/dist /app/frontend/dist
# Create data directory and non-root user
RUN groupadd -r iggy && \
useradd -r -g iggy -s /bin/false iggy && \
mkdir -p /data/performance_results && \
chown -R iggy:iggy /app /data && \
chmod -R 755 /data/performance_results
# Copy the entrypoint script
COPY docker-entrypoint.sh /app/
RUN chmod +x /app/docker-entrypoint.sh && \
chown iggy:iggy /app/docker-entrypoint.sh
# Set default environment variables for configuration
ENV HOST=0.0.0.0 \
PORT=80 \
RESULTS_DIR=/data/performance_results
# Set volume for results with proper permissions
VOLUME ["/data/performance_results"]
# Switch to non-root user
USER iggy
# Set the entrypoint script
ENTRYPOINT ["/app/docker-entrypoint.sh"]