Skip to content

Commit 64e374c

Browse files
committed
Make Docker CORRECTLY terminate
1 parent f6155eb commit 64e374c

File tree

3 files changed

+73
-28
lines changed

3 files changed

+73
-28
lines changed

.github/workflows/build-trios-trixie-dev.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,48 @@ jobs:
2222
shell: bash
2323
run: |
2424
_commit_hash=$(git rev-parse --short HEAD)
25+
_container_name="trios-builder-${_commit_hash}"
2526
2627
echo "${_commit_hash}" > ./Trixie/config/includes.chroot/etc/trios/release
2728
echo "commit_hash=${_commit_hash}" >> "$GITHUB_OUTPUT"
29+
echo "container_name=${_container_name}" >> "$GITHUB_OUTPUT"
30+
2831
mkdir -p ./TriOs_Output
2932
3033
- name: Debug commit hash
31-
run: |
32-
echo "Commit hash is: ${{ steps.vars.outputs.commit_hash }}"
34+
run: echo "Commit hash is: ${{ steps.vars.outputs.commit_hash }}"
3335

3436
- name: Build Docker Image
3537
working-directory: ./builder
36-
run: |
37-
docker build -t trios-builder .
38+
run: docker build -t trios-builder .
3839

3940
- name: Run Docker Container (Privileged)
41+
id: run_container
4042
run: |
41-
docker run --rm -i \
43+
set -e
44+
docker run -d \
4245
--privileged \
43-
-v "./Trixie:/TriOs" \
44-
-v "./TriOs_Output:/TriOs_Output" \
46+
--name "${{ steps.vars.outputs.container_name }}" \
47+
-v "${{ github.workspace }}/Trixie:/TriOs" \
48+
-v "${{ github.workspace }}/TriOs_Output:/TriOs_Output" \
4549
trios-builder
4650
47-
- name: Verify ISO Output
51+
# Attach to container to stream logs (will exit if container stops/fails)
52+
docker logs -f "${{ steps.vars.outputs.container_name }}"
53+
continue-on-error: true
54+
55+
- name: Stop Docker Container (always runs)
56+
if: always()
4857
run: |
49-
ls -lh ./TriOs_Output || true
58+
docker stop "${{ steps.vars.outputs.container_name }}" 2>/dev/null || true
59+
docker rm "${{ steps.vars.outputs.container_name }}" 2>/dev/null || true
60+
61+
- name: Verify ISO Output
62+
if: success()
63+
run: ls -lh ./TriOs_Output || true
5064

5165
- name: Upload ISO Artifact
66+
if: success()
5267
uses: actions/upload-artifact@v4
5368
with:
5469
name: trios-dev-${{ steps.vars.outputs.commit_hash }}.iso

.github/workflows/build-trios-trixie-nightly.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,48 @@ jobs:
2626
shell: bash
2727
run: |
2828
_timestamp=$(date -u +"%Y-%m-%dT%H-%M-%SZ")
29+
_container_name="trios-nightly-${_timestamp}"
2930
3031
echo "${_timestamp}" > ./Trixie/config/includes.chroot/etc/trios/release
3132
echo "timestamp=${_timestamp}" >> "$GITHUB_OUTPUT"
33+
echo "container_name=${_container_name}" >> "$GITHUB_OUTPUT"
34+
3235
mkdir -p ./TriOs_Output
3336
3437
- name: Debug timestamp
35-
run: |
36-
echo "Timestamp is: ${{ steps.vars.outputs.timestamp }}"
38+
run: echo "Timestamp is: ${{ steps.vars.outputs.timestamp }}"
3739

3840
- name: Build Docker Image
3941
working-directory: ./builder
40-
run: |
41-
docker build -t trios-builder .
42+
run: docker build -t trios-builder .
4243

4344
- name: Run Docker Container (Privileged)
45+
id: run_container
4446
run: |
45-
docker run --rm -i \
47+
set -e
48+
docker run -d \
4649
--privileged \
47-
-v "./Trixie:/TriOs" \
48-
-v "./TriOs_Output:/TriOs_Output" \
50+
--name "${{ steps.vars.outputs.container_name }}" \
51+
-v "${{ github.workspace }}/Trixie:/TriOs" \
52+
-v "${{ github.workspace }}/TriOs_Output:/TriOs_Output" \
4953
trios-builder
5054
51-
- name: Verify ISO Output
55+
# Stream container logs (exits if container stops/fails)
56+
docker logs -f "${{ steps.vars.outputs.container_name }}"
57+
continue-on-error: true
58+
59+
- name: Stop Docker Container (always runs)
60+
if: always()
5261
run: |
53-
ls -lh ./TriOs_Output || true
62+
docker stop "${{ steps.vars.outputs.container_name }}" 2>/dev/null || true
63+
docker rm "${{ steps.vars.outputs.container_name }}" 2>/dev/null || true
64+
65+
- name: Verify ISO Output
66+
if: success()
67+
run: ls -lh ./TriOs_Output || true
5468

5569
- name: Upload ISO Artifact
70+
if: success()
5671
uses: actions/upload-artifact@v4
5772
with:
5873
name: trios-nightly-${{ steps.vars.outputs.timestamp }}.iso

.github/workflows/build-trios-trixie-prod.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,54 @@ jobs:
2121
id: vars
2222
shell: bash
2323
run: |
24-
2524
if [ -f ./TriOs/Trixie/release_name ]; then
2625
_version=$(cat ./TriOs/Trixie/release_name | tr -d '\n\r')
2726
else
2827
_version="unknown"
2928
fi
3029
30+
_container_name="trios-prod-${_version}-$(date -u +%s)"
31+
3132
echo "${_version}" > ./Trixie/config/includes.chroot/etc/trios/release
3233
echo "version=${_version}" >> "$GITHUB_OUTPUT"
34+
echo "container_name=${_container_name}" >> "$GITHUB_OUTPUT"
35+
3336
mkdir -p ./TriOs_Output
3437
3538
- name: Debug version
36-
run: |
37-
echo "Version is: ${{ steps.vars.outputs.version }}"
39+
run: echo "Version is: ${{ steps.vars.outputs.version }}"
3840

3941
- name: Build Docker Image
4042
working-directory: ./builder
41-
run: |
42-
docker build -t trios-builder .
43+
run: docker build -t trios-builder .
4344

4445
- name: Run Docker Container (Privileged)
46+
id: run_container
4547
run: |
46-
docker run --rm -i \
48+
set -e
49+
docker run -d \
4750
--privileged \
48-
-v "./Trixie:/TriOs" \
49-
-v "./TriOs_Output:/TriOs_Output" \
51+
--name "${{ steps.vars.outputs.container_name }}" \
52+
-v "${{ github.workspace }}/Trixie:/TriOs" \
53+
-v "${{ github.workspace }}/TriOs_Output:/TriOs_Output" \
5054
trios-builder
5155
52-
- name: Verify ISO Output
56+
# Stream logs from container until it stops/fails
57+
docker logs -f "${{ steps.vars.outputs.container_name }}"
58+
continue-on-error: true
59+
60+
- name: Stop Docker Container (always runs)
61+
if: always()
5362
run: |
54-
ls -lh ./TriOs_Output || true
63+
docker stop "${{ steps.vars.outputs.container_name }}" 2>/dev/null || true
64+
docker rm "${{ steps.vars.outputs.container_name }}" 2>/dev/null || true
65+
66+
- name: Verify ISO Output
67+
if: success()
68+
run: ls -lh ./TriOs_Output || true
5569

5670
- name: Upload ISO Artifact
71+
if: success()
5772
uses: actions/upload-artifact@v4
5873
with:
5974
name: trios-prod-${{ steps.vars.outputs.version }}.iso

0 commit comments

Comments
 (0)