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: key: npm-cache paths: - .npm/ build-image: stage: build image: docker:27.0.3 services: - docker:dind before_script: - 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..." - 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..." - docker image prune -af --filter "until=72h" after_script: - echo "โœ… Build complete: $IMAGE_NAME" rules: - if: '$CI_COMMIT_BRANCH == "development"'