mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
Update .gitlab-ci.yml file
This commit is contained in:
+38
-3
@@ -1,5 +1,6 @@
|
|||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
- deploy
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
DOCKER_BUILDKIT: "1"
|
DOCKER_BUILDKIT: "1"
|
||||||
@@ -13,6 +14,9 @@ cache:
|
|||||||
paths:
|
paths:
|
||||||
- .npm/
|
- .npm/
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# 🏗️ BUILD STAGE
|
||||||
|
# =========================
|
||||||
build-image:
|
build-image:
|
||||||
stage: build
|
stage: build
|
||||||
image: docker:27.0.3
|
image: docker:27.0.3
|
||||||
@@ -25,12 +29,43 @@ build-image:
|
|||||||
|
|
||||||
script:
|
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 build --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from "$CI_REGISTRY_IMAGE/web-lti:latest" -t "$IMAGE_NAME" .
|
||||||
- docker push "$IMAGE_NAME"
|
- docker push "$IMAGE_NAME"
|
||||||
- echo "Cleaning old images (keep last 3)..."
|
- echo "Cleaning old images..."
|
||||||
- docker image prune -af --filter "until=72h"
|
- docker image prune -af --filter "until=72h"
|
||||||
|
|
||||||
after_script: "echo 'Build complete: $IMAGE_NAME'"
|
rules:
|
||||||
|
- if: '$CI_COMMIT_BRANCH == "development"'
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# 🚀 DEPLOY STAGE
|
||||||
|
# =========================
|
||||||
|
deploy-dev:
|
||||||
|
stage: deploy
|
||||||
|
image: alpine:3.20
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- echo "Installing dependencies..."
|
||||||
|
- apk add --no-cache openssh curl
|
||||||
|
- mkdir -p ~/.ssh
|
||||||
|
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
|
- chmod 600 ~/.ssh/id_rsa
|
||||||
|
- eval $(ssh-agent -s)
|
||||||
|
- ssh-add ~/.ssh/id_rsa
|
||||||
|
- ssh-keyscan -H "$SERVER_IP" >> ~/.ssh/known_hosts
|
||||||
|
|
||||||
|
script:
|
||||||
|
- echo "Deploying image to $SERVER_USER@$SERVER_IP"
|
||||||
|
- >
|
||||||
|
ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" "
|
||||||
|
docker pull $CI_REGISTRY_IMAGE/web-lti:development_${CI_COMMIT_SHORT_SHA} &&
|
||||||
|
docker stop dev-web-lti || true &&
|
||||||
|
docker rm dev-web-lti || true &&
|
||||||
|
docker run -d --name dev-web-lti \
|
||||||
|
--network dev-lti-network \
|
||||||
|
-p 3002:3000 \
|
||||||
|
$CI_REGISTRY_IMAGE/web-lti:development_${CI_COMMIT_SHORT_SHA}
|
||||||
|
"
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_BRANCH == "development"'
|
- if: '$CI_COMMIT_BRANCH == "development"'
|
||||||
Reference in New Issue
Block a user