-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
37 lines (27 loc) · 931 Bytes
/
Dockerfile
File metadata and controls
37 lines (27 loc) · 931 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
# Use the latest stable Python image
FROM python:3.14.2-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app
# Create app user and group
RUN groupadd --gid 1000 app && \
useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash app
# Create app directory and set ownership
RUN mkdir -p /app && \
chown -R app:app /app
# Set working directory
WORKDIR /app
# Copy requirements first for better Docker layer caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org -r requirements.txt
# Copy application code
COPY main.py .
# Change ownership of all files to app user
RUN chown -R app:app /app
# Switch to app user
USER app
# Set the default command
CMD ["python", "main.py"]