-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (34 loc) · 1.03 KB
/
Copy pathDockerfile
File metadata and controls
46 lines (34 loc) · 1.03 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
# Stage 1: Build stage
FROM python:3.11-slim as builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt
# Stage 2: Runtime stage
FROM python:3.11-slim
WORKDIR /app
# Create non-root user first
RUN useradd -m -u 1000 appuser
# Copy Python dependencies from builder
COPY --from=builder /root/.local /home/appuser/.local
# Copy application code
COPY main.py .
COPY config.yaml .
COPY modules/ ./modules/
COPY utils/ ./utils/
COPY locales/ ./locales/
# Create config and cache directories and set ownership
RUN mkdir -p /app/config .cache && \
chown -R appuser:appuser /app /home/appuser/.local
# Switch to non-root user
USER appuser
# Make sure scripts in .local are usable
ENV PATH=/home/appuser/.local/bin:$PATH
# Set default command
ENTRYPOINT ["python", "main.py"]
CMD ["--config", "config.yaml"]