-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (30 loc) · 1005 Bytes
/
Dockerfile
File metadata and controls
44 lines (30 loc) · 1005 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
# Use the official Rust image as the base
FROM rust:1.90 AS builder
# Set working directory
WORKDIR /app
# Copy the Cargo.toml and Cargo.lock files
COPY Cargo.toml Cargo.lock ./
# Create a dummy main.rs to cache dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs
# Build dependencies (this layer will be cached if Cargo.toml doesn't change)
RUN cargo build --release && rm -rf src
# Copy the actual source code
COPY src ./src
# Build the application
RUN cargo build --release
# Runtime stage
FROM debian:bookworm-slim
# Create a non-root user
RUN useradd -r -s /bin/false appuser
# Set working directory
WORKDIR /app
# Copy the binary from builder stage
COPY --from=builder /app/target/release/server /app/server
# Change ownership to appuser (but keep certs readable)
RUN chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Expose the ports (9816 for HTTP, 55688 for wstcp proxy)
EXPOSE 9816 55688
# Run the binary
CMD ["sh", "-c", "RUST_LOG=Debug ./server"]