-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (35 loc) · 1.01 KB
/
Copy pathDockerfile
File metadata and controls
49 lines (35 loc) · 1.01 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
# Use the official Rust image for building
FROM rust:latest as builder
# Set the working directory
WORKDIR /app
# Copy the Cargo.toml and Cargo.lock files
COPY Cargo.toml Cargo.lock ./
# Copy the workspace configuration
COPY entity/ ./entity/
COPY migration/ ./migration/
# Copy the source code
COPY src/ ./src/
# Build the application in release mode
RUN cargo build --release
# Use a smaller base image for the runtime
FROM debian:bookworm-slim
# Install required runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
libpq5 \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -s /bin/bash appuser
# Set the working directory
WORKDIR /app
# Copy the binary from the builder stage
COPY --from=builder /app/target/release/centralized-exchange ./
# Change ownership to the non-root user
RUN chown -R appuser:appuser /app
# Switch to the non-root user
USER appuser
# Expose the port
EXPOSE 8080
# Run the application
CMD ["./centralized-exchange"]