-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
28 lines (21 loc) · 842 Bytes
/
Dockerfile
File metadata and controls
28 lines (21 loc) · 842 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
FROM python:3.11-slim
# Set environment variables:
# PYTHONDONTWRITEBYTECODE: Prevents Python from writing .pyc files to disk
# PYTHONUNBUFFERED: Prevents Python from buffering stdout and stderr
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Create a non-root user and group
RUN groupadd -r appuser && useradd -m -r -g appuser appuser
# Set working directory
WORKDIR /app
# Copy the project files
COPY . /app/
# Install the project and dependencies without cache to keep the image small
# Also change ownership of the application code to the non-root user
RUN pip install --no-cache-dir . && \
chown -R appuser:appuser /app
# Switch to the non-root user for security
USER appuser
# Default command to run
# Replace 'python' with your specific entrypoint, like 'python -m python_infra_lab' or your CLI tool
CMD ["python"]