diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef90f0d306318120def6d138f5031094e37bc6a7..d4a76ecaaf14a41eb851bd508bff3e481c7008ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,9 @@ -# The Docker image that will be used to build your app -image: node:19.5-bullseye-slim # Functions that should be executed before the build script is run +variables: + HELM_VERSION: "3.9.3" + IMAGE_NAME: "df-wiki" + cache: paths: - node_modules/ @@ -10,7 +12,6 @@ stages: - build - deploy - .build: stage: build image: docker:24 @@ -24,7 +25,6 @@ stages: - docker build --pull -t "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA" --build-arg="BUILD_OPTIONS=$OPTIONS" -f $DOCKERFILE $CONTEXT - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$CI_COMMIT_SHORT_SHA" - # build: # stage: build # before_script: @@ -38,23 +38,49 @@ stages: # when: on_success # expire_in: "30 days" - -build:dev:nuxt: +build:dev: extends: .build - variables: - IMAGE_NAME: "df-wiki" rules: - if: $CI_COMMIT_BRANCH != "main" -# pages: -# stage: deploy -# only: -# - main -# script: -# - NUXT_APP_BASE_URL=/wiki npm run generate -# - rm -rf public -# - mv .output/public public -# artifacts: -# paths: -# # The folder that contains the files to be exposed at the Page URL -# - public +.deploy: + stage: deploy + image: harbor.pasteur.fr/kube-system/helm-kubectl:$HELM_VERSION + variables: + CI_DEBUG_TRACE: "true" + TEAM_ID: "df" + script: + - > + helm upgrade --install $CI_PROJECT_NAME-$CI_ENVIRONMENT_NAME ./deploy/ --namespace=${KUBE_NAMESPACE} + --set registry.image=${CI_REGISTRY_IMAGE} + --set registry.username=${DEPLOY_USER} + --set registry.password=${DEPLOY_TOKEN} + --set registry.host=${CI_REGISTRY} + --set imagePullSecrets[0].name="registry-pull-secret-${CI_COMMIT_REF_SLUG}" + --set ingress.enabled="true" + --set ingress.hosts[0].host="${PUBLIC_URL}" + --set ingress.hosts[0].paths[0].path="/" + --set ingress.annotations."kubernetes\.io/ingress\.class"="$INGRESS_CLASS" + --set image.repository="$CI_REGISTRY_IMAGE/$IMAGE_NAME" + --set image.tag="$CI_COMMIT_SHORT_SHA" + --set image.pullPolicy='Always' + --set env="$ENV" + +deploy:dev: + extends: .deploy + rules: + - if: $CI_COMMIT_BRANCH != "main" + needs: + - "build:dev" + variables: + NODE_ENV: "development" + KUBE_NAMESPACE: "defense-finder-dev" + PUBLIC_URL: "defense-finder.dev.pasteur.cloud" + INGRESS_CLASS: "internal" + AUTOSCALE: "true" + AUTSCALING_MIN_REPLICAS: "1" + AUTSCALING_MAX_REPLICAS: "4" + ENV: "development" + environment: + name: k8sdev-01 + url: "https://defense-finder.dev.pasteur.cloud"