-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
83 lines (63 loc) · 2.05 KB
/
Dockerfile
File metadata and controls
83 lines (63 loc) · 2.05 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Multi-stage build for SOAR
FROM oven/bun:1-alpine AS web-builder
# Install dependencies and build the web frontend
WORKDIR /app/web
COPY web/package.json web/bun.lock ./
RUN bun install --frozen-lockfile
COPY web/ ./
RUN bun run build
# Rust build stage
FROM rust:1-slim-bookworm AS rust-builder
# Install system dependencies for building
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Copy Rust configuration files
COPY Cargo.toml Cargo.lock build.rs ./
COPY src/ ./src/
COPY migrations/ ./migrations/
COPY static/ ./static/
# Copy the built web assets from previous stage
COPY --from=web-builder /app/web/build/ ./web/build/
COPY --from=web-builder /app/web/package.json ./web/
# Build the Rust application in release mode
# Set SKIP_WEB_BUILD because web is already built in the web-builder stage
RUN SKIP_WEB_BUILD=1 cargo build --release
# Runtime stage
FROM debian:bookworm-slim
# Install runtime dependencies including debug symbols for Sentry symbolication
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
libpq5 \
libc6-dbg \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN groupadd -r soar && useradd -r -g soar soar
# Create app directory
WORKDIR /app
# Copy the built binary
COPY --from=rust-builder /app/target/release/soar /usr/local/bin/soar
# Make sure the binary is executable
RUN chmod +x /usr/local/bin/soar
# Change ownership to the soar user
RUN chown soar:soar /app
# Switch to non-root user
USER soar
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD soar --help > /dev/null || exit 1
# Default command
CMD ["soar", "--help"]
# Expose default web server port
EXPOSE 61225
# Add labels for metadata
LABEL org.opencontainers.image.title="SOAR"
LABEL org.opencontainers.image.description="SOAR - Soaring Observation And Records"
LABEL org.opencontainers.image.vendor="SOAR Project"
LABEL org.opencontainers.image.licenses="MIT"