+43
Dockerfile
+43
Dockerfile
···
···
1
+
# Use the official Rust image
2
+
FROM rust:1.75-slim as builder
3
+
4
+
# Set working directory
5
+
WORKDIR /app
6
+
7
+
# Copy manifest files
8
+
COPY Cargo.toml Cargo.lock ./
9
+
10
+
# Copy source code
11
+
COPY src ./src
12
+
13
+
# Build the application
14
+
RUN cargo build --release
15
+
16
+
# Runtime stage
17
+
FROM debian:bookworm-slim
18
+
19
+
# Install runtime dependencies
20
+
RUN apt-get update && apt-get install -y \
21
+
ca-certificates \
22
+
&& rm -rf /var/lib/apt/lists/*
23
+
24
+
# Create app user
25
+
RUN useradd -r -s /bin/false appuser
26
+
27
+
# Set working directory
28
+
WORKDIR /app
29
+
30
+
# Copy the binary from builder stage
31
+
COPY --from=builder /app/target/release/discordhose /app/discordhose
32
+
33
+
# Change ownership to app user
34
+
RUN chown -R appuser:appuser /app
35
+
36
+
# Switch to app user
37
+
USER appuser
38
+
39
+
# Expose port (if needed in the future)
40
+
EXPOSE 8080
41
+
42
+
# Run the application
43
+
CMD ["./discordhose"]