-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (49 loc) · 1.62 KB
/
Dockerfile
File metadata and controls
65 lines (49 loc) · 1.62 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
59
60
61
62
63
64
65
# ==============================================================================
# Devabase Backend Dockerfile
# Multi-stage build for optimized production image
# ==============================================================================
# Stage 1: Build
FROM rust:latest AS builder
WORKDIR /app
# Install dependencies for pdf-extract and other native libs
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
libpq-dev \
cmake \
&& rm -rf /var/lib/apt/lists/*
# Copy all source code and build
COPY Cargo.toml Cargo.lock ./
COPY src ./src
COPY migrations ./migrations
# Build the application
RUN cargo build --release
# Stage 2: Runtime (use same base as builder for GLIBC compatibility)
FROM debian:trixie-slim AS runtime
WORKDIR /app
# Build argument for port
ARG BACKEND_PORT=9002
ENV DEVABASE_PORT=${BACKEND_PORT}
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
libpq5 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy binary from builder
COPY --from=builder /app/target/release/devabase /usr/local/bin/devabase
# Copy migrations
COPY --from=builder /app/migrations /app/migrations
# Create data directory
RUN mkdir -p /app/data && chown -R 1000:1000 /app/data
# Create non-root user
RUN useradd -r -u 1000 -s /bin/false devabase
USER devabase
# Expose port (uses build arg)
EXPOSE ${BACKEND_PORT}
# Health check (uses environment variable)
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${DEVABASE_PORT}/v1/health || exit 1
# Run the application
CMD ["devabase", "serve"]