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