-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (44 loc) · 1.22 KB
/
Dockerfile
File metadata and controls
58 lines (44 loc) · 1.22 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
# Use multi-stage build for smaller final image
# Build stage
FROM rust:1.88-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
libpq-dev \
build-essential \
clang \
libclang-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy Cargo files and source code
COPY Cargo.toml Cargo.lock ./
COPY pg2any-lib/ ./pg2any-lib/
COPY examples/ ./examples/
WORKDIR /app/examples
# Build the application
RUN cargo build --release
# Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Create non-root user
RUN useradd -r -u 1001 -g root pg2any_user
# Copy the binary from builder stage
COPY --from=builder /app/target/release/pg2any /usr/local/bin/pg2any
# Change ownership to non-root user
RUN chown -R pg2any_user:root /app
# Switch to non-root user
USER pg2any_user
# Expose port (if needed for health checks or metrics)
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD pgrep -f pg2any || exit 1
# Run the application
CMD ["pg2any"]