-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
32 lines (23 loc) · 859 Bytes
/
Copy pathDockerfile
File metadata and controls
32 lines (23 loc) · 859 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
# syntax=docker/dockerfile:1
FROM python:3.11-slim AS base
# Keep Python fast and predictable in containers
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
# System deps for typical Python builds (remove if unnecessary)
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential curl && \
rm -rf /var/lib/apt/lists/*
# Install Python dependencies first to leverage Docker layer caching
COPY requirements.txt* /app/
RUN if [ -f requirements.txt ]; then pip install --no-cache-dir -r requirements.txt; fi
# Copy the rest of the application
COPY . /app
# Run as non-root for better security
RUN useradd -m appuser && chown -R appuser /app
USER appuser
EXPOSE 8000
# Override this in docker-compose.yml as needed
CMD ["python", "main.py"]