-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (47 loc) · 1.31 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (47 loc) · 1.31 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
51
52
53
54
55
56
57
58
# syntax=docker/dockerfile:1
############################
# 1️⃣ Base Image
############################
FROM python:3.12-slim AS base
# Environment settings
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PORT=8080
WORKDIR /app
############################
# 2️⃣ System Dependencies
############################
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
############################
# 3️⃣ Install Python Dependencies
############################
COPY requirements.txt .
RUN pip install --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
############################
# 4️⃣ Create Non-Root User
############################
RUN addgroup --system appgroup && \
adduser --system --ingroup appgroup appuser
############################
# 5️⃣ Copy Application Code
############################
COPY . .
############################
# 6️⃣ Switch to Non-Root User
############################
USER appuser
############################
# 7️⃣ Expose Cloud Run Port
############################
EXPOSE 8080
############################
# 8️⃣ Production Server Command
############################
CMD ["uvicorn", "app.v1.app:app", \
"--host", "0.0.0.0", \
"--port", "8080", \
"--workers", "2"]