Update .gitlab-ci.yml file

This commit is contained in:
kris
2025-11-09 08:05:11 +00:00
parent 2d649eb0ff
commit a9620246c0
+4 -12
View File
@@ -2,15 +2,10 @@ stages:
- build
variables:
# 🔧 Aktifkan Docker BuildKit (build lebih cepat & caching layer)
DOCKER_BUILDKIT: "1"
COMPOSE_DOCKER_CLI_BUILD: "1"
DOCKER_DRIVER: overlay2
# 🧠 Nama image (pakai commit short SHA)
IMAGE_NAME: "$CI_REGISTRY_IMAGE/web-lti:development_${CI_COMMIT_SHORT_SHA}"
# Cache npm (disimpan antar pipeline)
NPM_CACHE_DIR: "$CI_PROJECT_DIR/.npm"
cache:
@@ -25,20 +20,17 @@ build-image:
- docker:dind
before_script:
- echo "🔐 Logging in to GitLab Container Registry..."
- echo "Logging in to GitLab Container Registry..."
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
script:
- echo "🚧 Building optimized Docker image..."
- echo "Building optimized Docker image..."
- docker build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from $CI_REGISTRY_IMAGE/web-lti:latest -t "$IMAGE_NAME" .
- docker push "$IMAGE_NAME"
# 🧹 Keep only last 3 images (hapus yang lama)
- echo "🧹 Cleaning old images..."
- echo "Cleaning old images (keep last 3)..."
- docker image prune -af --filter "until=72h"
after_script:
- echo "✅ Build complete: $IMAGE_NAME"
after_script: "echo 'Build complete: $IMAGE_NAME'"
rules:
- if: '$CI_COMMIT_BRANCH == "development"'