Optimise docker build space usage (#10224)

* Use BuildKit builder instead of legacy one

Signed-off-by: Artem Savchenko <armisav@gmail.com>

* fix: use slim docker image

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>

* Add dockerignore

Signed-off-by: Artem Savchenko <armisav@gmail.com>

* Clean up build artifacts

Signed-off-by: Artem Savchenko <armisav@gmail.com>

* Clean up

Signed-off-by: Artem Savchenko <armisav@gmail.com>

* Fix flag

Signed-off-by: Artem Savchenko <armisav@gmail.com>

---------

Signed-off-by: Artem Savchenko <armisav@gmail.com>
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
Co-authored-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Artyom Savchenko
2025-11-17 21:50:06 +07:00
committed by GitHub
co-authored by Alexander Onnikov
parent 01ebea2a99
commit 1cd34ea353
2 changed files with 34 additions and 0 deletions
+7
View File
@@ -245,6 +245,7 @@ jobs:
run: node common/scripts/install-run-rush.js docker
env:
DOCKER_CLI_HINTS: false
DOCKER_BUILDKIT: 1
- name: Configure /etc/hosts
run: |
sudo echo "127.0.0.1 huly.local" | sudo tee -a /etc/hosts
@@ -375,6 +376,7 @@ jobs:
run: node common/scripts/install-run-rush.js docker
env:
DOCKER_CLI_HINTS: false
DOCKER_BUILDKIT: 1
- name: Configure /etc/hosts
run: |
sudo echo "127.0.0.1 huly.local" | sudo tee -a /etc/hosts
@@ -469,6 +471,7 @@ jobs:
run: node common/scripts/install-run-rush.js docker
env:
DOCKER_CLI_HINTS: false
DOCKER_BUILDKIT: 1
- name: Configure /etc/hosts
run: |
sudo echo "127.0.0.1 huly.local" | sudo tee -a /etc/hosts
@@ -550,6 +553,7 @@ jobs:
run: node common/scripts/install-run-rush.js docker
env:
DOCKER_CLI_HINTS: false
DOCKER_BUILDKIT: 1
- name: Configure /etc/hosts
run: |
sudo echo "127.0.0.1 huly.local" | sudo tee -a /etc/hosts
@@ -674,6 +678,8 @@ jobs:
env:
DOCKER_CLI_HINTS: false
DOCKER_EXTRA: --platform=linux/amd64,linux/arm64
DOCKER_BUILDKIT: 1
DOCKER_BUILD_CLEANUP: true
- name: Docker build love-agent
run: |
cd ./services/ai-bot/love-agent
@@ -682,6 +688,7 @@ jobs:
env:
DOCKER_CLI_HINTS: false
DOCKER_EXTRA: --platform=linux/amd64,linux/arm64
DOCKER_BUILDKIT: 1
- name: Login to Docker Hub
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/s') }}
uses: docker/login-action@v3
+27
View File
@@ -2,6 +2,33 @@
version=$(git rev-parse HEAD)
# Check for cleanup flag from environment
cleanup=false
if [ "$DOCKER_BUILD_CLEANUP" = "true" ]; then
cleanup=true
fi
echo "Building version: $version"
docker build -t "$1" -t "$1:$version" ${DOCKER_EXTRA} .
if [ "$cleanup" = true ]; then
echo "Cleaning up build artifacts..."
if [ -d "bundle" ]; then
echo " Removing bundle/"
rm -rf bundle
fi
if [ -d "dist" ]; then
echo " Removing dist/"
rm -rf dist
fi
if [ -d ".rush" ]; then
echo " Removing .rush/"
rm -rf .rush
fi
echo " Size after cleanup: $(du -sh . 2>/dev/null | cut -f1)"
fi