Skip to content
Snippets Groups Projects
Commit 957a5130 authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

ci: clean up

parent 801c041b
No related branches found
No related tags found
No related merge requests found
variables: variables:
DOCKER_TLS_CERTDIR: "" # HACK: see https://gitlab.com/gitlab-org/gitlab-runner/issues/4501 DOCKER_TLS_CERTDIR: "" # HACK: see https://gitlab.com/gitlab-org/gitlab-runner/issues/4501
DOCKER_IMAGE: "docker:20.10.12"
stages: stages:
- setup - setup
...@@ -8,7 +7,9 @@ stages: ...@@ -8,7 +7,9 @@ stages:
- build - build
- deploy - deploy
#==[ Node jobs templates ]====================================================== # TODO: maybe stup some notifications as a last stage?
#==[ JOB TEMPLATES ]============================================================
.node-job: &node-job .node-job: &node-job
image: node:16-alpine image: node:16-alpine
...@@ -42,7 +43,9 @@ stages: ...@@ -42,7 +43,9 @@ stages:
- cd backend - cd backend
- npm ci --cache .npm --prefer-offline - npm ci --cache .npm --prefer-offline
#==[ Frontent cache ]=========================================================== #==[ SETUP STAGE ]==============================================================
#--[ Frontend ]-----------------------------------------------------------------
cache-fe-node-job: cache-fe-node-job:
extends: .fe-node-job extends: .fe-node-job
...@@ -50,7 +53,7 @@ cache-fe-node-job: ...@@ -50,7 +53,7 @@ cache-fe-node-job:
script: script:
- echo "Done!" - echo "Done!"
#==[ Backend cache ]============================================================ #--[ Backend ]------------------------------------------------------------------
cache-be-node-job: cache-be-node-job:
extends: .be-node-job extends: .be-node-job
...@@ -58,7 +61,9 @@ cache-be-node-job: ...@@ -58,7 +61,9 @@ cache-be-node-job:
script: script:
- echo "Done!" - echo "Done!"
#==[ Frontend checks ]========================================================== #==[ CHECK STAGE ]==============================================================
#--[ Frontend ]-----------------------------------------------------------------
.check-fe-node-job: &check-fe-node-job .check-fe-node-job: &check-fe-node-job
extends: .fe-node-job extends: .fe-node-job
...@@ -81,7 +86,7 @@ test-fe-node-job: ...@@ -81,7 +86,7 @@ test-fe-node-job:
script: script:
- npm run test - npm run test
#==[ Backend checks ]=========================================================== #--[ Backend ]------------------------------------------------------------------
.check-be-node-job: &check-be-node-job .check-be-node-job: &check-be-node-job
extends: .be-node-job extends: .be-node-job
...@@ -104,12 +109,39 @@ test-be-node-job: ...@@ -104,12 +109,39 @@ test-be-node-job:
script: script:
- npm run test - npm run test
#==[ Backend build ]============================================================ #==[ BUILD STAGE ]==============================================================
#--[ Frontend ]-----------------------------------------------------------------
.fe-build-job:
image: node:16-alpine
stage: build
tags:
- commul
cache:
- key:
files:
- frontend/package-lock.json
paths:
- frontend/node_modules
script:
- cd frontend
- npm install
- npm run build
artifacts:
paths:
- frontend/dist/
# TODO: set expiration in docker registry too
expire_in: 1 week
only:
- tags
- development
#--[ Backend ]------------------------------------------------------------------
# TODO: cache docker layers # TODO: cache docker layers
# TODO: build ts
.be-build-job: .be-build-job:
image: $DOCKER_IMAGE image: docker:20.10.12
stage: build stage: build
tags: tags:
- commul - commul
...@@ -133,110 +165,86 @@ test-be-node-job: ...@@ -133,110 +165,86 @@ test-be-node-job:
- tags - tags
- development - development
#==[ Backend deployment ]======================================================= #==[ DEPLOY STAGE ]=============================================================
.be-deploy-job: #--[ Frontend ]-----------------------------------------------------------------
.fe-deploy-job:
image: alpine:latest image: alpine:latest
stage: deploy stage: deploy
needs: needs:
- job: be-build-job - job: fe-build-job
artifacts: false artifacts: true
tags: tags:
- commul - commul
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE/backend
before_script: before_script:
- ./ci/install-kubectl-on-alpine.sh - ./ci/install-butler-on-alpine.sh
script: script:
- kubectl set image deployment/${K8S_DEPLOYMENT} oetzi=${IMAGE_NAME}:${CI_COMMIT_SHA} --namespace=${K8S_NAMESPACE} - >
butler push
frontend/dist
eurac/$GAME_NAME:html5
--userversion ${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
.be-prd-deploy-job: .fe-prd-deploy-job:
extends: .be-deploy-job extends: .fe-deploy-job
environment: environment:
name: production/backend name: production/frontend
deployment_tier: production deployment_tier: production
url: https://kommul.eurac.edu/oetzi url: https://eurac.itch.io/oetzi
variables: variables:
K8S_NAMESPACE: kommul GAME_NAME: oetzi
K8S_DEPLOYMENT: oetzi-webserver-deployment
only: only:
- tags - tags
.be-stg-deploy-job: .fe-stg-deploy-job:
extends: .be-deploy-job extends: .fe-deploy-job
environment: environment:
name: staging/backend name: staging/frontend
deployment_tier: staging deployment_tier: staging
url: https://kommul-dev.eurac.edu/oetzi url: https://eurac.itch.io/oetzi-staging
variables: variables:
K8S_NAMESPACE: kommul-dev GAME_NAME: oetzi-staging
K8S_DEPLOYMENT: oetzi-webserver-deployment
only:
- development
#==[ Frontend build ]===========================================================
.fe-build-job:
image: node:16-alpine
stage: build
tags:
- commul
cache:
- key:
files:
- frontend/package-lock.json
paths:
- frontend/node_modules
script:
- cd frontend
- npm install
- npm run build
artifacts:
paths:
- frontend/dist/
# TODO: set expiration in docker registry too
expire_in: 1 week
only: only:
- tags
- development - development
#==[ Frontend deployment ]====================================================== #--[ Backend ]------------------------------------------------------------------
.fe-deploy-job: .be-deploy-job:
image: alpine:latest image: alpine:latest
stage: deploy stage: deploy
needs: needs:
- job: fe-build-job - job: be-build-job
artifacts: true artifacts: false
tags: tags:
- commul - commul
variables:
IMAGE_NAME: $CI_REGISTRY_IMAGE/backend
before_script: before_script:
- ./ci/install-butler-on-alpine.sh - ./ci/install-kubectl-on-alpine.sh
script: script:
- > - kubectl set image deployment/${K8S_DEPLOYMENT} oetzi=${IMAGE_NAME}:${CI_COMMIT_SHA} --namespace=${K8S_NAMESPACE}
butler push
frontend/dist
eurac/$GAME_NAME:html5
--userversion ${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}
.fe-prd-deploy-job: .be-prd-deploy-job:
extends: .fe-deploy-job extends: .be-deploy-job
environment: environment:
name: production/frontend name: production/backend
deployment_tier: production deployment_tier: production
url: https://eurac.itch.io/oetzi url: https://kommul.eurac.edu/oetzi
variables: variables:
GAME_NAME: oetzi K8S_NAMESPACE: kommul
K8S_DEPLOYMENT: oetzi-webserver-deployment
only: only:
- tags - tags
.fe-stg-deploy-job: .be-stg-deploy-job:
extends: .fe-deploy-job extends: .be-deploy-job
environment: environment:
name: staging/frontend name: staging/backend
deployment_tier: staging deployment_tier: staging
url: https://eurac.itch.io/oetzi-staging url: https://kommul-dev.eurac.edu/oetzi
variables: variables:
GAME_NAME: oetzi-staging K8S_NAMESPACE: kommul-dev
K8S_DEPLOYMENT: oetzi-webserver-deployment
only: only:
- development - development
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment