mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
44 lines
1.2 KiB
YAML
44 lines
1.2 KiB
YAML
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"' |