-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
70 lines (53 loc) · 1.65 KB
/
Copy pathDockerfile
File metadata and controls
70 lines (53 loc) · 1.65 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
# syntax=docker/dockerfile:1
# Build stage
FROM registry.access.redhat.com/ubi9/ubi:latest AS builder
# Install Python 3.12 and build dependencies
RUN dnf install -y \
python3.12 \
python3.12-pip \
python3.12-devel \
gcc \
postgresql-devel \
&& dnf clean all
# Create virtual environment
RUN python3.12 -m venv /opt/venv
# Enable virtual environment
ENV PATH="/opt/venv/bin:$PATH"
# Copy project files
WORKDIR /build
COPY pyproject.toml README.md ./
COPY src/ ./src/
# Install chantal and dependencies
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir .
# Runtime stage
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
# Install runtime dependencies
RUN microdnf install -y \
python3.12 \
libpq \
shadow-utils \
&& microdnf clean all
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
# Enable virtual environment
ENV PATH="/opt/venv/bin:$PATH"
# Create chantal user and directories
RUN useradd -r -u 1000 -d /var/lib/chantal -s /sbin/nologin chantal && \
mkdir -p /etc/chantal/conf.d /var/lib/chantal /var/www/repos && \
chown -R chantal:chantal /etc/chantal /var/lib/chantal /var/www/repos
# Set working directory
WORKDIR /var/lib/chantal
# Switch to non-root user
USER chantal
# Define volumes
VOLUME ["/etc/chantal", "/var/lib/chantal", "/var/www/repos"]
# Set environment variables
ENV CHANTAL_CONFIG=/etc/chantal/config.yaml \
PYTHONUNBUFFERED=1
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD chantal --version || exit 1
# Default command
ENTRYPOINT ["chantal"]
CMD ["--help"]