-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (27 loc) · 995 Bytes
/
Copy pathDockerfile
File metadata and controls
37 lines (27 loc) · 995 Bytes
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
FROM python:3.11-slim
WORKDIR /app
# Install dependencies (add wget and jq for Vault integration)
RUN apt-get update && apt-get install -y wget jq && rm -rf /var/lib/apt/lists/*
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application
COPY app/ ./app/
# Copy tests and pytest configuration
COPY tests/ ./tests/
COPY pytest.ini ./pytest.ini
# Copy startup scripts
COPY start.sh /app/start.sh
COPY init.sh /app/init.sh
RUN chmod +x /app/start.sh /app/init.sh
# Create non-root user and set ownership
RUN groupadd -r appuser && useradd -r -g appuser appuser && \
chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Expose ports (HTTP and HTTPS)
EXPOSE 8000 8443
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
# Run initialization script (which calls start.sh)
CMD ["/app/init.sh"]