Skip to content

Commit 07a1286

Browse files
Refactor Dockerfile to multi-stage build for incremental caching on failures (#2)
* Initial plan * Refactor Dockerfile to multi-stage build with independent caching Co-authored-by: shimaenaga1123 <88320744+shimaenaga1123@users.noreply.github.com> * Fix ENV format to use = instead of space Co-authored-by: shimaenaga1123 <88320744+shimaenaga1123@users.noreply.github.com> * Quote command substitutions to prevent word splitting Co-authored-by: shimaenaga1123 <88320744+shimaenaga1123@users.noreply.github.com> * Add documentation and verify cache invalidation on version updates Co-authored-by: shimaenaga1123 <88320744+shimaenaga1123@users.noreply.github.com> * Remove documentation file per requirements Co-authored-by: shimaenaga1123 <88320744+shimaenaga1123@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: shimaenaga1123 <88320744+shimaenaga1123@users.noreply.github.com>
1 parent ee2b35a commit 07a1286

File tree

3 files changed

+330
-528
lines changed

3 files changed

+330
-528
lines changed

.github/workflows/README.md

Lines changed: 0 additions & 162 deletions
This file was deleted.

.github/workflows/docker-build-test-deploy.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ jobs:
5555
echo "Checking version consistency across Dockerfile and tests..."
5656
errors=0
5757
58-
# Sample version checks
59-
gcc_version=$(grep -A 1 'ENV GCC_VERSIONS' Dockerfile | tail -1 | xargs)
58+
# Sample version checks (updated for singular VERSION env vars)
59+
gcc_version=$(grep 'ENV GCC_VERSION=' Dockerfile | cut -d'=' -f2)
6060
gcc_test=$(grep '^VERSIONS=' tests/gcc/lang.properties | cut -d'"' -f2)
6161
if [ "$gcc_version" != "$gcc_test" ]; then
6262
echo "❌ GCC version mismatch: Dockerfile=$gcc_version, Test=$gcc_test"
@@ -65,7 +65,7 @@ jobs:
6565
echo "✓ GCC: $gcc_version"
6666
fi
6767
68-
python_version=$(grep -A 1 'ENV PYTHON_VERSIONS' Dockerfile | tail -1 | xargs)
68+
python_version=$(grep 'ENV PYTHON_VERSION=' Dockerfile | cut -d'=' -f2)
6969
python_test=$(grep '^VERSIONS=' tests/python/lang.properties | cut -d'"' -f2)
7070
if [ "$python_version" != "$python_test" ]; then
7171
echo "❌ Python version mismatch: Dockerfile=$python_version, Test=$python_test"
@@ -74,7 +74,7 @@ jobs:
7474
echo "✓ Python: $python_version"
7575
fi
7676
77-
node_version=$(grep -A 1 'ENV NODE_VERSIONS' Dockerfile | tail -1 | xargs)
77+
node_version=$(grep 'ENV NODE_VERSION=' Dockerfile | cut -d'=' -f2)
7878
node_test=$(grep '^VERSIONS=' tests/node/lang.properties | cut -d'"' -f2)
7979
if [ "$node_version" != "$node_test" ]; then
8080
echo "❌ Node version mismatch: Dockerfile=$node_version, Test=$node_test"
@@ -122,13 +122,17 @@ jobs:
122122
type=semver,pattern={{major}}
123123
type=sha
124124
125+
# Build Docker image using multi-stage Dockerfile
126+
# Each stage is cached independently, so if a build fails at a later stage,
127+
# earlier stages are preserved and don't need to be rebuilt
125128
- name: Build Docker image
126129
uses: docker/build-push-action@v5
127130
with:
128131
context: .
129132
push: false
130133
load: true
131134
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
135+
target: final
132136
cache-from: type=gha
133137
cache-to: type=gha,mode=max
134138
build-args: |
@@ -276,6 +280,7 @@ jobs:
276280
push: true
277281
tags: ${{ steps.meta.outputs.tags }}
278282
labels: ${{ steps.meta.outputs.labels }}
283+
target: final
279284
cache-from: type=gha
280285
cache-to: type=gha,mode=max
281286
build-args: |

0 commit comments

Comments
 (0)