-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·55 lines (41 loc) · 1.48 KB
/
Dockerfile
File metadata and controls
executable file
·55 lines (41 loc) · 1.48 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
# Multi-stage build for smaller production image
FROM python:3.12-slim as builder
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
WORKDIR /app
COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt
# Production stage
FROM python:3.12-slim
# Install runtime dependencies only
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get autoremove -y
# Create non-root user
RUN useradd --create-home --shell /bin/bash --uid 1000 appuser
# Copy Python packages from builder
COPY --from=builder /root/.local /home/appuser/.local
# Set up application
WORKDIR /app
COPY --chown=appuser:appuser app ./app
# Create required directories with proper permissions
RUN mkdir -p /app/logs /app/shared_host_folder \
&& chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Add local Python packages to PATH
ENV PATH=/home/appuser/.local/bin:$PATH
# Production configuration
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
AUDIT_LOG_FILE=/app/logs/audit.log \
MCP_BASE_WORKING_DIR=/app/shared_host_folder
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
CMD ["python", "-m", "app.main"]