-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (41 loc) · 2.03 KB
/
Copy pathDockerfile
File metadata and controls
50 lines (41 loc) · 2.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
47
48
49
50
# --------------------------------------------------------------------
# Base image
# --------------------------------------------------------------------
FROM python:3.13-slim
# --------------------------------------------------------------------
# Build arguments (available only during image build)
# --------------------------------------------------------------------
ARG BUILD_DATE="1970-01-01T00:00:00Z"
# --------------------------------------------------------------------
# OCI image metadata
# https://github.com/opencontainers/image-spec/blob/main/annotations.md
# --------------------------------------------------------------------
LABEL org.opencontainers.image.authors="emmanuel.bruno@univ-tln.fr" \
org.opencontainers.image.created="${BUILD_DATE}"
# --------------------------------------------------------------------
# Environment variables
# --------------------------------------------------------------------
ENV NAME="John Doe"
# --------------------------------------------------------------------
# Application directory
# --------------------------------------------------------------------
WORKDIR /app
# --------------------------------------------------------------------
# Install Python dependencies
# Copy requirements first to maximize Docker cache reuse.
# --------------------------------------------------------------------
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# --------------------------------------------------------------------
# Copy application source
# --------------------------------------------------------------------
COPY hello.py .
# --------------------------------------------------------------------
# Run as a non-root user (container security best practice)
# --------------------------------------------------------------------
RUN useradd --create-home appuser
USER appuser
# --------------------------------------------------------------------
# Default command
# --------------------------------------------------------------------
ENTRYPOINT ["python", "hello.py"]