|
1 | 1 | # ─────────────────────────────
|
2 |
| -# ⚡ Use Slim Python Base |
| 2 | +# ⚡ Base Image: Slim & Fast |
3 | 3 | # ─────────────────────────────
|
4 | 4 | FROM python:3.12-slim-bookworm
|
5 | 5 |
|
6 | 6 | # ─────────────────────────────
|
7 |
| -# 🧼 Set Environment Vars |
8 |
| -# ───────────────────────────── |
9 |
| -ARG BUILD_MODE=remote |
10 |
| -ENV BUILD_MODE=${BUILD_MODE} |
11 |
| -ENV PORT=8501 |
12 |
| - |
13 |
| -# ───────────────────────────── |
14 |
| -# 🛠 Install Required OS Packages (only essentials) |
| 7 | +# 📦 Install OS Dependencies |
15 | 8 | # ─────────────────────────────
|
16 | 9 | RUN apt-get update && apt-get install -y --no-install-recommends \
|
17 | 10 | git \
|
18 | 11 | gcc \
|
19 |
| - libpq-dev \ |
20 | 12 | curl \
|
| 13 | + libpq-dev \ |
21 | 14 | && apt-get clean \
|
22 | 15 | && rm -rf /var/lib/apt/lists/*
|
23 | 16 |
|
24 | 17 | # ─────────────────────────────
|
25 |
| -# 📦 Install Python Packages |
| 18 | +# 🔁 Set Build Mode Variable |
26 | 19 | # ─────────────────────────────
|
27 |
| -# Always set working dir to avoid weird pip behavior |
28 |
| -WORKDIR /app |
| 20 | +ARG BUILD_MODE=remote |
| 21 | +ENV BUILD_MODE=${BUILD_MODE} |
29 | 22 |
|
30 |
| -# Copy early if needed for layer caching |
31 |
| -COPY requirements.txt requirements.txt |
32 |
| -RUN pip install --no-cache-dir -r requirements.txt |
| 23 | +# ───────────────────────────── |
| 24 | +# ⏳ Work in Temporary Directory |
| 25 | +# ───────────────────────────── |
| 26 | +WORKDIR /tmp/build-context |
33 | 27 |
|
34 | 28 | # ─────────────────────────────
|
35 |
| -# 📁 Clone or Copy Code |
| 29 | +# 🧱 Clone or Copy App Code |
36 | 30 | # ─────────────────────────────
|
37 |
| -# Remote clone |
38 | 31 | RUN if [ "$BUILD_MODE" = "remote" ]; then \
|
39 |
| - git clone https://github.com/curiouslearning/cl-dashboard-internal.git /app ; \ |
| 32 | + git clone https://github.com/curiouslearning/cl-dashboard-internal.git /cl-dashboard-internal ; \ |
40 | 33 | fi
|
41 | 34 |
|
42 |
| -# Local copy |
43 | 35 | COPY . /tmp/local-copy
|
44 | 36 | RUN if [ "$BUILD_MODE" = "local" ]; then \
|
45 |
| - cp -r /tmp/local-copy/* /app ; \ |
| 37 | + cp -r /tmp/local-copy /cl-dashboard-internal ; \ |
46 | 38 | fi
|
47 | 39 |
|
48 | 40 | # ─────────────────────────────
|
49 |
| -# ▶ Entrypoint |
| 41 | +# 📦 Install Python Requirements |
50 | 42 | # ─────────────────────────────
|
| 43 | +WORKDIR /cl-dashboard-internal |
| 44 | +COPY requirements.txt requirements.txt # In case not already copied |
| 45 | +RUN pip install --no-cache-dir -r requirements.txt |
| 46 | + |
| 47 | +# ───────────────────────────── |
| 48 | +# 🎯 Set Entrypoint for Cloud Run |
| 49 | +# ───────────────────────────── |
| 50 | +ENV PORT=8501 |
51 | 51 | COPY entrypoint.sh /entrypoint.sh
|
52 | 52 | RUN chmod +x /entrypoint.sh
|
53 | 53 |
|
|
0 commit comments