-
Notifications
You must be signed in to change notification settings - Fork 9.7k
195 lines (176 loc) · 7.83 KB
/
Copy pathdocker_test.yml
File metadata and controls
195 lines (176 loc) · 7.83 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
name: Test Docker images
on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true
workflow_dispatch:
env:
POETRY_VERSION: "1.8.2"
jobs:
test-docker:
runs-on: [self-hosted, linux, ARM64, langflow-ai-arm64-40gb-ephemeral]
name: Test docker images
steps:
- uses: actions/checkout@v6
- name: Set container runtime
run: |
if command -v docker &> /dev/null; then
echo "CONTAINER_RUNTIME=docker" >> $GITHUB_ENV
elif command -v podman &> /dev/null; then
echo "CONTAINER_RUNTIME=podman" >> $GITHUB_ENV
else
echo "Error: Neither docker nor podman found"
exit 1
fi
echo "Using container runtime: ${{ env.CONTAINER_RUNTIME }}"
- name: Docker System Info and Cleanup
run: |
echo "=== Docker System Usage Before Cleanup ==="
${{ env.CONTAINER_RUNTIME }} system df || true
if command -v docker &> /dev/null; then
docker buildx du || true
fi
echo "=== Cleaning up Docker System ==="
${{ env.CONTAINER_RUNTIME }} system prune -af --volumes || true
if command -v docker &> /dev/null; then
docker buildx prune -af || true
fi
echo "=== Docker System Usage After Cleanup ==="
${{ env.CONTAINER_RUNTIME }} system df || true
if command -v docker &> /dev/null; then
docker buildx du || true
fi
- name: Login to Docker Hub
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build image
run: |
${{ env.CONTAINER_RUNTIME }} build -t langflowai/langflow:latest-dev \
-f docker/build_and_push.Dockerfile \
.
- name: Test image
run: |
expected_version=$(cat pyproject.toml | grep version | head -n 1 | cut -d '"' -f 2)
version=$(${{ env.CONTAINER_RUNTIME }} run --rm --entrypoint bash langflowai/langflow:latest-dev -c "python -c 'from langflow.utils.version import get_version_info; print(get_version_info()[\"version\"])'")
if [ "$expected_version" != "$version" ]; then
echo "Expected version: $expected_version"
echo "Actual version: $version"
exit 1
fi
- name: Cleanup after main image
run: |
echo "=== Disk usage before cleanup ==="
df -h /
${{ env.CONTAINER_RUNTIME }} rmi langflowai/langflow:latest-dev || true
${{ env.CONTAINER_RUNTIME }} system prune -af || true
if command -v docker &> /dev/null; then
docker buildx prune -af || true
fi
echo "=== Disk usage after cleanup ==="
df -h /
- name: Build core image
run: |
${{ env.CONTAINER_RUNTIME }} build -t langflowai/langflow:core-latest-dev \
-f docker/build_and_push_core.Dockerfile \
.
- name: Test core image
run: |
expected_version=$(grep '^version = ' src/langflow-core/pyproject.toml | head -n 1 | cut -d '"' -f 2)
version=$(${{ env.CONTAINER_RUNTIME }} run --rm --entrypoint python langflowai/langflow:core-latest-dev -c 'from importlib.metadata import version; print(version("langflow-core"))')
if [ "$expected_version" != "$version" ]; then
echo "Expected core version: $expected_version"
echo "Actual core version: $version"
exit 1
fi
${{ env.CONTAINER_RUNTIME }} run --rm --entrypoint python langflowai/langflow:core-latest-dev -c '
import importlib.metadata as metadata
names = {dist.metadata["Name"].lower() for dist in metadata.distributions()}
required = {"langflow-core", "langflow-base", "lfx", "langflow-sdk"}
missing = sorted(required - names)
forbidden = sorted(name for name in names if name.startswith("lfx-"))
assert not missing, f"missing core distributions: {missing}"
assert not forbidden, f"extension distributions installed: {forbidden}"
'
${{ env.CONTAINER_RUNTIME }} run --rm --entrypoint bash langflowai/langflow:core-latest-dev -c '
command -v langflow >/dev/null
command -v langflow-core >/dev/null
'
container_id=$(${{ env.CONTAINER_RUNTIME }} run -d \
-e LANGFLOW_SUPERUSER_PASSWORD=CoreImageTest-2026! \
langflowai/langflow:core-latest-dev)
cleanup_core_container() {
${{ env.CONTAINER_RUNTIME }} rm -f "$container_id" >/dev/null 2>&1 || true
}
trap cleanup_core_container EXIT
healthy=false
for _ in $(seq 1 60); do
if ${{ env.CONTAINER_RUNTIME }} exec "$container_id" curl -fsS http://127.0.0.1:7860/health_check >/dev/null; then
healthy=true
break
fi
if [ "$(${{ env.CONTAINER_RUNTIME }} inspect -f '{{.State.Running}}' "$container_id" 2>/dev/null)" != "true" ]; then
break
fi
sleep 2
done
if [ "$healthy" != "true" ]; then
echo "Core image did not become healthy"
${{ env.CONTAINER_RUNTIME }} logs "$container_id" || true
exit 1
fi
cleanup_core_container
trap - EXIT
- name: Cleanup after core image
if: always()
run: |
echo "=== Disk usage before cleanup ==="
df -h /
while read -r container_id; do
if [ -n "$container_id" ]; then
${{ env.CONTAINER_RUNTIME }} rm -f "$container_id" 2>/dev/null || true
fi
done < <(${{ env.CONTAINER_RUNTIME }} ps -aq --filter ancestor=langflowai/langflow:core-latest-dev)
${{ env.CONTAINER_RUNTIME }} rmi langflowai/langflow:core-latest-dev || true
${{ env.CONTAINER_RUNTIME }} system prune -af || true
if command -v docker &> /dev/null; then
docker buildx prune -af || true
fi
echo "=== Disk usage after cleanup ==="
df -h /
- name: Build backend image
run: |
${{ env.CONTAINER_RUNTIME }} build -t langflowai/langflow-backend:latest-dev \
--build-arg LANGFLOW_IMAGE=langflowai/langflow:latest-dev \
-f docker/build_and_push_backend.Dockerfile \
.
- name: Test backend image
run: |
expected_version=$(cat src/backend/base/pyproject.toml | grep version | head -n 1 | cut -d '"' -f 2)
version=$(${{ env.CONTAINER_RUNTIME }} run --rm --entrypoint bash langflowai/langflow-backend:latest-dev -c "python -c 'from langflow.utils.version import get_version_info; print(get_version_info()[\"version\"])'")
if [ "$expected_version" != "$version" ]; then
echo "Expected version: $expected_version"
echo "Actual version: $version"
exit 1
fi
- name: Cleanup after backend image
run: |
echo "=== Disk usage before cleanup ==="
df -h /
${{ env.CONTAINER_RUNTIME }} rmi langflowai/langflow-backend:latest-dev || true
${{ env.CONTAINER_RUNTIME }} system prune -af || true
if command -v docker &> /dev/null; then
docker buildx prune -af || true
fi
echo "=== Disk usage after cleanup ==="
df -h /
- name: Build frontend image
run: |
${{ env.CONTAINER_RUNTIME }} build -t langflowai/langflow-frontend:latest-dev \
-f docker/frontend/build_and_push_frontend.Dockerfile \
.