Skip to content

Commit b545dca

Browse files
committed
requiremts fix
1 parent 8f58343 commit b545dca

File tree

3 files changed

+187
-163
lines changed

3 files changed

+187
-163
lines changed

.github/workflows/main.yaml

Lines changed: 141 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -12,140 +12,153 @@ on:
1212
- '.github/workflows/**'
1313
- 'demo/demo-1-basics/**'
1414
- 'demo/demo-2-otel/**'
15-
1615
workflow_dispatch:
1716

1817
jobs:
1918
podman-compose:
2019
runs-on: ubuntu-latest
2120

2221
env:
23-
TMPDIR: /tmp
24-
XDG_RUNTIME_DIR: /tmp/podman-run
22+
# ✅ MUST be user-owned paths
23+
XDG_RUNTIME_DIR: ${{ github.workspace }}/podman-runtime
24+
TMPDIR: ${{ github.workspace }}/podman-tmp
25+
PODMAN_STORAGE: ${{ github.workspace }}/podman-storage
2526

2627
steps:
27-
# --------------------------------------------------
28-
# 1️⃣ Checkout
29-
# --------------------------------------------------
30-
- name: Checkout repository
31-
uses: actions/checkout@v4
32-
33-
# --------------------------------------------------
34-
# 2️⃣ Install Podman & podman-compose
35-
# --------------------------------------------------
36-
- name: Install Podman & podman-compose
37-
run: |
38-
sudo apt-get update -y
39-
sudo apt-get install -y podman python3-pip uidmap
40-
pip install --upgrade pip
41-
pip install podman-compose
42-
podman --version
43-
44-
# --------------------------------------------------
45-
# 3️⃣ Configure Podman runtime (CRITICAL FIX)
46-
# --------------------------------------------------
47-
- name: Configure Podman runtime (cgroupfs)
48-
run: |
49-
mkdir -p ~/.config/containers
50-
cat <<EOF > ~/.config/containers/containers.conf
51-
[engine]
52-
cgroup_manager = "cgroupfs"
53-
runtime = "crun"
54-
EOF
55-
56-
mkdir -p $XDG_RUNTIME_DIR
57-
chmod 700 $XDG_RUNTIME_DIR
58-
59-
podman info | grep -i cgroup
60-
61-
# --------------------------------------------------
62-
# 4️⃣ Configure Podman storage (avoid disk full)
63-
# --------------------------------------------------
64-
- name: Configure Podman storage
65-
run: |
66-
STORAGE_ROOT="/home/runner/work/_containers"
67-
sudo mkdir -p "$STORAGE_ROOT" /etc/containers
68-
69-
cat <<EOF | sudo tee /etc/containers/storage.conf
70-
[storage]
71-
driver = "overlay"
72-
graphroot = "$STORAGE_ROOT"
73-
runroot = "/tmp/podman-runroot"
74-
EOF
75-
76-
podman system migrate
77-
78-
# --------------------------------------------------
79-
# 5️⃣ Pre-cleanup (important for CI stability)
80-
# --------------------------------------------------
81-
- name: Pre-build cleanup
82-
run: |
83-
podman ps -aq | xargs -r podman stop || true
84-
podman ps -aq | xargs -r podman rm -f || true
85-
podman images -aq | xargs -r podman rmi -f || true
86-
podman volume prune -f || true
87-
podman network prune -f || true
88-
podman system prune -a -f || true
89-
90-
# --------------------------------------------------
91-
# 6️⃣ Create required Podman network
92-
# --------------------------------------------------
93-
- name: Create Podman network
94-
run: |
95-
podman network exists anomaly-network || \
96-
podman network create anomaly-network
97-
98-
# --------------------------------------------------
99-
# 7️⃣ Build & Run demo-1-basics
100-
# --------------------------------------------------
101-
- name: Run demo-1-basics
102-
working-directory: demo/demo-1-basics
103-
run: |
104-
echo "Running demo-1-basics..."
105-
podman-compose build
106-
podman-compose up -d
107-
108-
podman ps -a
109-
podman-compose logs || true
110-
111-
podman-compose down -v
112-
113-
# --------------------------------------------------
114-
# 8️⃣ Cleanup between demos (VERY IMPORTANT)
115-
# --------------------------------------------------
116-
- name: Cleanup between demos
117-
run: |
118-
podman system prune -a -f
119-
podman network prune -f || true
120-
121-
# --------------------------------------------------
122-
# 9️⃣ Re-create network for next demo
123-
# --------------------------------------------------
124-
- name: Re-create Podman network
125-
run: |
126-
podman network exists anomaly-network || \
127-
podman network create anomaly-network
128-
129-
# --------------------------------------------------
130-
# 🔟 Build & Run demo-2-otel
131-
# --------------------------------------------------
132-
- name: Run demo-2-otel
133-
working-directory: demo/demo-2-otel
134-
run: |
135-
echo "Running demo-2-otel..."
136-
podman-compose build
137-
podman-compose up -d
138-
139-
podman ps -a
140-
podman-compose logs || true
141-
142-
podman-compose down -v
143-
144-
# --------------------------------------------------
145-
# 1️⃣1️⃣ Final cleanup
146-
# --------------------------------------------------
147-
- name: Final cleanup
148-
if: always()
149-
run: |
150-
podman system prune -a -f
151-
podman network prune -f || true
28+
# --------------------------------------------------
29+
# 1️⃣ Checkout
30+
# --------------------------------------------------
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
# --------------------------------------------------
35+
# 2️⃣ Free disk space (CRITICAL)
36+
# --------------------------------------------------
37+
- name: Free disk space
38+
run: |
39+
sudo rm -rf /usr/share/dotnet
40+
sudo rm -rf /usr/local/lib/android
41+
sudo rm -rf /opt/ghc
42+
sudo docker image prune -a -f || true
43+
df -h
44+
45+
# --------------------------------------------------
46+
# 3️⃣ Install Podman & podman-compose
47+
# --------------------------------------------------
48+
- name: Install Podman & podman-compose
49+
run: |
50+
sudo apt-get update -y
51+
sudo apt-get install -y podman uidmap python3-pip
52+
pip install --upgrade pip
53+
pip install podman-compose
54+
podman --version
55+
podman-compose --version
56+
57+
# --------------------------------------------------
58+
# 4️⃣ Configure Podman runtime (NO systemd)
59+
# --------------------------------------------------
60+
- name: Configure Podman runtime
61+
run: |
62+
mkdir -p ~/.config/containers
63+
cat <<EOF > ~/.config/containers/containers.conf
64+
[engine]
65+
cgroup_manager = "cgroupfs"
66+
runtime = "crun"
67+
events_logger = "file"
68+
EOF
69+
70+
# --------------------------------------------------
71+
# 5️⃣ Configure Podman storage + runtime dirs
72+
# --------------------------------------------------
73+
- name: Configure Podman storage
74+
run: |
75+
mkdir -p "$XDG_RUNTIME_DIR" "$TMPDIR" "$PODMAN_STORAGE"
76+
chmod 700 "$XDG_RUNTIME_DIR"
77+
chmod 777 "$TMPDIR" "$PODMAN_STORAGE"
78+
79+
mkdir -p ~/.config/containers
80+
cat <<EOF > ~/.config/containers/storage.conf
81+
[storage]
82+
driver = "overlay"
83+
graphroot = "$PODMAN_STORAGE"
84+
runroot = "$XDG_RUNTIME_DIR/runroot"
85+
EOF
86+
87+
podman system migrate
88+
podman info
89+
90+
# --------------------------------------------------
91+
# 6️⃣ Hard cleanup before builds
92+
# --------------------------------------------------
93+
- name: Pre-build cleanup
94+
run: |
95+
podman ps -aq | xargs -r podman rm -f || true
96+
podman images -aq | xargs -r podman rmi -f || true
97+
podman volume prune -f || true
98+
podman network prune -f || true
99+
podman system prune -a -f || true
100+
101+
# --------------------------------------------------
102+
# 7️⃣ Create shared network
103+
# --------------------------------------------------
104+
- name: Create Podman network
105+
run: |
106+
podman network exists anomaly-network || \
107+
podman network create anomaly-network
108+
109+
# --------------------------------------------------
110+
# 8️⃣ demo-1-basics
111+
# --------------------------------------------------
112+
- name: Run demo-1-basics
113+
working-directory: demo/demo-1-basics
114+
run: |
115+
echo "Running demo-1-basics..."
116+
podman-compose build --no-cache
117+
podman-compose up -d
118+
119+
podman ps -a
120+
podman-compose logs || true
121+
122+
podman-compose down -v
123+
124+
# --------------------------------------------------
125+
# 9️⃣ Cleanup between demos (MANDATORY)
126+
# --------------------------------------------------
127+
- name: Cleanup between demos
128+
run: |
129+
podman system prune -a -f
130+
podman volume prune -f || true
131+
podman network prune -f || true
132+
133+
# --------------------------------------------------
134+
# 🔟 Re-create network
135+
# --------------------------------------------------
136+
- name: Re-create Podman network
137+
run: |
138+
podman network exists anomaly-network || \
139+
podman network create anomaly-network
140+
141+
# --------------------------------------------------
142+
# 1️⃣1️⃣ demo-2-otel
143+
# --------------------------------------------------
144+
- name: Run demo-2-otel
145+
working-directory: demo/demo-2-otel
146+
run: |
147+
echo "Running demo-2-otel..."
148+
podman-compose build --no-cache
149+
podman-compose up -d
150+
151+
podman ps -a
152+
podman-compose logs || true
153+
154+
podman-compose down -v
155+
156+
# --------------------------------------------------
157+
# 1️⃣2️⃣ Final cleanup
158+
# --------------------------------------------------
159+
- name: Final cleanup
160+
if: always()
161+
run: |
162+
podman system prune -a -f
163+
podman network prune -f || true
164+
df -h
Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,55 @@
1+
# ✅ Podman + GitHub Actions safe base image
12
FROM python:3.11-slim-bookworm
23

3-
# -------------------------------
4-
# Working directory
5-
# -------------------------------
64
WORKDIR /app
75

8-
# -------------------------------
9-
# System dependencies (single layer)
10-
# -------------------------------
6+
# -----------------------------
7+
# System deps (MINIMAL)
8+
# -----------------------------
119
RUN apt-get update && apt-get install -y \
12-
curl \
1310
gcc \
1411
python3-dev \
1512
build-essential \
16-
wget \
1713
&& rm -rf /var/lib/apt/lists/*
1814

19-
# -------------------------------
20-
# Directories required for OpenShift / HuggingFace
21-
# (OpenShift runs with random UID)
22-
# -------------------------------
23-
RUN mkdir -p /app \
24-
/tmp/huggingface \
25-
/tmp/huggingface/transformers \
26-
&& chmod -R 777 /app /tmp/huggingface
27-
28-
# -------------------------------
29-
# Environment hardening (CRITICAL)
30-
# -------------------------------
15+
# -----------------------------
16+
# Runtime dirs (OpenShift-safe)
17+
# -----------------------------
18+
RUN mkdir -p /app /tmp/huggingface /tmp/pip-cache \
19+
&& chmod -R 777 /app /tmp/huggingface /tmp/pip-cache
20+
21+
# -----------------------------
22+
# Environment hard fixes
23+
# -----------------------------
3124
ENV PYTHONPATH=/app
3225
ENV PYTHONUNBUFFERED=1
3326

34-
# HuggingFace caches
27+
# HuggingFace cache
3528
ENV HF_HOME=/tmp/huggingface
3629
ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
3730

38-
# 🚫 Disable pip cache (fixes overlayfs failures)
31+
# 🚫 Podman disk explosion fixes
3932
ENV PIP_NO_CACHE_DIR=1
4033
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
34+
ENV PIP_CACHE_DIR=/tmp/pip-cache
35+
ENV PIP_PREFER_BINARY=1
4136

42-
# 🚫 Prevent CUDA / NVIDIA probing
37+
# 🚫 HARD block GPU / CUDA wheels
4338
ENV CUDA_VISIBLE_DEVICES=""
4439
ENV TORCH_CUDA_ARCH_LIST=""
40+
ENV TRANSFORMERS_NO_TF=1
41+
ENV TRANSFORMERS_NO_FLAX=1
4542

46-
# -------------------------------
47-
# Python dependencies
48-
# -------------------------------
43+
# -----------------------------
44+
# Python deps (single layer)
45+
# -----------------------------
4946
COPY requirements.txt .
50-
RUN pip install --no-cache-dir -r requirements.txt
47+
RUN pip install --no-cache-dir --prefer-binary -r requirements.txt \
48+
&& rm -rf /tmp/pip-cache
5149

52-
# -------------------------------
53-
# Application source
54-
# -------------------------------
50+
# -----------------------------
51+
# App source
52+
# -----------------------------
5553
COPY . .
5654

57-
# -------------------------------
58-
# Run FastAPI
59-
# -------------------------------
6055
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8002"]

0 commit comments

Comments
 (0)