update gitlab file
This commit is contained in:
+60
-24
@@ -14,7 +14,8 @@ variables:
|
|||||||
# TEST STAGE
|
# TEST STAGE
|
||||||
# Runs on every push and merge request
|
# Runs on every push and merge request
|
||||||
# ====================================
|
# ====================================
|
||||||
unit_tests:
|
|
||||||
|
api_tests:
|
||||||
stage: test
|
stage: test
|
||||||
image: node:20-bookworm
|
image: node:20-bookworm
|
||||||
before_script:
|
before_script:
|
||||||
@@ -24,8 +25,41 @@ unit_tests:
|
|||||||
- npm run type-check
|
- npm run type-check
|
||||||
- npm run test:api
|
- npm run test:api
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||||
|
|
||||||
|
marketplace_tests:
|
||||||
|
stage: test
|
||||||
|
image: node:20-bookworm
|
||||||
|
before_script:
|
||||||
|
- npm ci
|
||||||
|
script:
|
||||||
|
- npm run test:marketplace
|
||||||
|
rules:
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||||
|
|
||||||
|
admin_tests:
|
||||||
|
stage: test
|
||||||
|
image: node:20-bookworm
|
||||||
|
before_script:
|
||||||
|
- npm ci
|
||||||
|
script:
|
||||||
|
- npm run test:admin
|
||||||
|
rules:
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||||
|
|
||||||
|
dashboard_tests:
|
||||||
|
stage: test
|
||||||
|
image: node:20-bookworm
|
||||||
|
before_script:
|
||||||
|
- npm ci
|
||||||
|
script:
|
||||||
|
- npm run test:dashboard
|
||||||
|
rules:
|
||||||
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||||
|
|
||||||
integration_tests:
|
integration_tests:
|
||||||
stage: test
|
stage: test
|
||||||
@@ -62,12 +96,13 @@ integration_tests:
|
|||||||
script:
|
script:
|
||||||
- npm run test:api:integration
|
- npm run test:api:integration
|
||||||
rules:
|
rules:
|
||||||
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||||
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||||
|
|
||||||
# ====================================
|
# ====================================
|
||||||
# BUILD STAGE
|
# BUILD STAGE
|
||||||
# ====================================
|
# ====================================
|
||||||
|
|
||||||
build_image:
|
build_image:
|
||||||
stage: build
|
stage: build
|
||||||
image: docker:24
|
image: docker:24
|
||||||
@@ -162,19 +197,19 @@ build_image:
|
|||||||
export ADMIN_INTERNAL_URL="${ADMIN_INTERNAL_URL:-http://admin:3002}"
|
export ADMIN_INTERNAL_URL="${ADMIN_INTERNAL_URL:-http://admin:3002}"
|
||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
--build-arg API_INTERNAL_URL=$API_INTERNAL_URL \
|
--build-arg API_INTERNAL_URL="$API_INTERNAL_URL" \
|
||||||
--build-arg DASHBOARD_INTERNAL_URL=$DASHBOARD_INTERNAL_URL \
|
--build-arg DASHBOARD_INTERNAL_URL="$DASHBOARD_INTERNAL_URL" \
|
||||||
--build-arg ADMIN_INTERNAL_URL=$ADMIN_INTERNAL_URL \
|
--build-arg ADMIN_INTERNAL_URL="$ADMIN_INTERNAL_URL" \
|
||||||
--build-arg NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL \
|
--build-arg NEXT_PUBLIC_API_URL="$NEXT_PUBLIC_API_URL" \
|
||||||
--build-arg NEXT_PUBLIC_MARKETPLACE_URL=$NEXT_PUBLIC_MARKETPLACE_URL \
|
--build-arg NEXT_PUBLIC_MARKETPLACE_URL="$NEXT_PUBLIC_MARKETPLACE_URL" \
|
||||||
--build-arg NEXT_PUBLIC_DASHBOARD_URL=$NEXT_PUBLIC_DASHBOARD_URL \
|
--build-arg NEXT_PUBLIC_DASHBOARD_URL="$NEXT_PUBLIC_DASHBOARD_URL" \
|
||||||
--build-arg NEXT_PUBLIC_ADMIN_URL=$NEXT_PUBLIC_ADMIN_URL \
|
--build-arg NEXT_PUBLIC_ADMIN_URL="$NEXT_PUBLIC_ADMIN_URL" \
|
||||||
-t $DOCKER_IMAGE \
|
-t "$DOCKER_IMAGE" \
|
||||||
-t $DOCKER_IMAGE_LATEST \
|
-t "$DOCKER_IMAGE_LATEST" \
|
||||||
-f $DOCKERFILE_PATH .
|
-f "$DOCKERFILE_PATH" .
|
||||||
- echo "--- Pushing to Registry ---"
|
- echo "--- Pushing to Registry ---"
|
||||||
- docker push $DOCKER_IMAGE
|
- docker push "$DOCKER_IMAGE"
|
||||||
- docker push $DOCKER_IMAGE_LATEST
|
- docker push "$DOCKER_IMAGE_LATEST"
|
||||||
rules:
|
rules:
|
||||||
# On the default branch, always attempt the image build so missing registry
|
# On the default branch, always attempt the image build so missing registry
|
||||||
# configuration fails loudly in before_script instead of skipping the job.
|
# configuration fails loudly in before_script instead of skipping the job.
|
||||||
@@ -184,6 +219,7 @@ build_image:
|
|||||||
# ====================================
|
# ====================================
|
||||||
# DEPLOY STAGE
|
# DEPLOY STAGE
|
||||||
# ====================================
|
# ====================================
|
||||||
|
|
||||||
deploy_to_vps:
|
deploy_to_vps:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
@@ -210,7 +246,7 @@ deploy_to_vps:
|
|||||||
- export DOCKER_IMAGE="$IMAGE_REPOSITORY:$CI_COMMIT_SHORT_SHA"
|
- export DOCKER_IMAGE="$IMAGE_REPOSITORY:$CI_COMMIT_SHORT_SHA"
|
||||||
- apk add --no-cache openssh-client
|
- apk add --no-cache openssh-client
|
||||||
# Load the SSH private key stored in the CI variable SSH_PRIVATE_KEY
|
# Load the SSH private key stored in the CI variable SSH_PRIVATE_KEY
|
||||||
- eval $(ssh-agent -s)
|
- eval "$(ssh-agent -s)"
|
||||||
- |
|
- |
|
||||||
key_file="$(mktemp)"
|
key_file="$(mktemp)"
|
||||||
decoded_key_file="$(mktemp)"
|
decoded_key_file="$(mktemp)"
|
||||||
@@ -251,7 +287,7 @@ deploy_to_vps:
|
|||||||
trap - EXIT
|
trap - EXIT
|
||||||
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||||
# Scan and trust the VPS host key (avoids manual known_hosts management)
|
# Scan and trust the VPS host key (avoids manual known_hosts management)
|
||||||
- ssh-keyscan -H $VPS_IP >> ~/.ssh/known_hosts
|
- ssh-keyscan -H "$VPS_IP" >> ~/.ssh/known_hosts
|
||||||
- chmod 644 ~/.ssh/known_hosts
|
- chmod 644 ~/.ssh/known_hosts
|
||||||
script:
|
script:
|
||||||
- echo "--- Deploying $DOCKER_IMAGE to VPS ---"
|
- echo "--- Deploying $DOCKER_IMAGE to VPS ---"
|
||||||
@@ -259,16 +295,16 @@ deploy_to_vps:
|
|||||||
REGISTRY_PASSWORD_B64="$(printf '%s' "$REGISTRY_PASSWORD" | base64 | tr -d '\n')"
|
REGISTRY_PASSWORD_B64="$(printf '%s' "$REGISTRY_PASSWORD" | base64 | tr -d '\n')"
|
||||||
|
|
||||||
echo "-- Syncing deployment assets --"
|
echo "-- Syncing deployment assets --"
|
||||||
ssh $VPS_USER@$VPS_IP "
|
ssh "$VPS_USER@$VPS_IP" "
|
||||||
set -e
|
set -e
|
||||||
mkdir -p '$DEPLOY_ROOT/scripts' '$DEPLOY_ROOT/docker/pgmanage' '$DEPLOY_ROOT/docker/registry/auth' '$DEPLOY_ROOT/dynamic'
|
mkdir -p '$DEPLOY_ROOT/scripts' '$DEPLOY_ROOT/docker/pgmanage' '$DEPLOY_ROOT/docker/registry/auth' '$DEPLOY_ROOT/dynamic'
|
||||||
"
|
"
|
||||||
scp docker-compose.production.yml docker-compose.portainer.production.yml docker-compose.registry.production.yml docker-compose.registry.local.yml traefik.yaml $VPS_USER@$VPS_IP:$DEPLOY_ROOT/
|
scp docker-compose.production.yml docker-compose.portainer.production.yml docker-compose.registry.production.yml docker-compose.registry.local.yml traefik.yaml "$VPS_USER@$VPS_IP:$DEPLOY_ROOT/"
|
||||||
scp scripts/docker-prod-common.sh scripts/docker-prod-deploy.sh scripts/docker-prod-up-registry.sh scripts/docker-registry-local-up.sh $VPS_USER@$VPS_IP:$DEPLOY_ROOT/scripts/
|
scp scripts/docker-prod-common.sh scripts/docker-prod-deploy.sh scripts/docker-prod-up-registry.sh scripts/docker-registry-local-up.sh "$VPS_USER@$VPS_IP:$DEPLOY_ROOT/scripts/"
|
||||||
scp docker/pgmanage/override.py $VPS_USER@$VPS_IP:$DEPLOY_ROOT/docker/pgmanage/
|
scp docker/pgmanage/override.py "$VPS_USER@$VPS_IP:$DEPLOY_ROOT/docker/pgmanage/"
|
||||||
|
|
||||||
echo "-- Running deploy script on VPS --"
|
echo "-- Running deploy script on VPS --"
|
||||||
ssh $VPS_USER@$VPS_IP "
|
ssh "$VPS_USER@$VPS_IP" "
|
||||||
set -e
|
set -e
|
||||||
cd '$DEPLOY_ROOT'
|
cd '$DEPLOY_ROOT'
|
||||||
APP_IMAGE='$IMAGE_REPOSITORY' \
|
APP_IMAGE='$IMAGE_REPOSITORY' \
|
||||||
|
|||||||
Reference in New Issue
Block a user