-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
72 lines (55 loc) · 1.83 KB
/
Copy pathDockerfile
File metadata and controls
72 lines (55 loc) · 1.83 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
# Relay Dockerfile
# Multi-stage build for optimized image size
# ---- Builder Stage ----
FROM python:3.11-slim AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy project metadata and source
COPY pyproject.toml README.md ./
COPY gateway/ ./gateway/
COPY auth/ ./auth/
COPY backends/ ./backends/
COPY config/ ./config/
COPY connectors/ ./connectors/
COPY security/ ./security/
COPY observability/ ./observability/
COPY patroclus/ ./patroclus/
# Build wheels
RUN pip install --no-cache-dir build && \
pip wheel --no-cache-dir --wheel-dir /wheels .
# ---- Runtime Stage ----
FROM python:3.11-slim
WORKDIR /app
# Create non-root user with fixed UID/GID for volume permissions
RUN groupadd -r -g 1000 relay && useradd -r -g relay -u 1000 relay
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy wheels from builder and install
COPY --from=builder /wheels /wheels
RUN pip install --no-cache-dir /wheels/*.whl && rm -rf /wheels
# Copy application code (templates, static files not in package)
COPY --chown=relay:relay . .
# Create directories with correct ownership
RUN mkdir -p logs data && chown -R relay:relay logs data
# Switch to non-root user
USER relay
# Environment defaults
ENV RELAY_ENVIRONMENT=production \
RELAY_SERVER__HOST=0.0.0.0 \
RELAY_SERVER__PORT=8000 \
RELAY_SERVER__LOG_FORMAT=json \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD curl -f http://localhost:8000/live || exit 1
# Default command
CMD ["relay", "serve", "--host", "0.0.0.0", "--port", "8000"]