Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.53 KiB
variables:
  DOCKER_TLS_CERTDIR: "" # HACK: see https://gitlab.com/gitlab-org/gitlab-runner/issues/4501

stages:
  - build
  - deploy
  - setup

.be-build-job:
  variables:
    IMAGE_NAME: $CI_REGISTRY_IMAGE/backend
  stage: build
  image: docker:latest
  services:
    - docker:dind
  before_script:
    - docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN https://$CI_REGISTRY
  script:
    - >
      docker build
      --rm --no-cache
      --target production
      --tag=$IMAGE_NAME:${CI_COMMIT_SHA}
      --tag=$IMAGE_NAME:${CI_COMMIT_REF_NAME}
      backend
    - docker image push --all-tags $IMAGE_NAME
  only:
    - main

.be-deploy-job:
  variables:
    KUBECTL_VERSION: v1.8.10
    IMAGE_NAME: $CI_REGISTRY_IMAGE/backend

  stage: deploy
  tags:
    - commul
  image: docker:latest
  services:
    - docker:dind
  before_script:
    - wget https://storage.googleapis.com/kubernetes-release/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl
    # NOTE: version is too ald and don't have sha256 available
    #- wget https://dl.k8s.io/release/$KUBECTL_VERSION/bin/linux/amd64/kubectl.sha256
    # - echo "$(<kubectl.sha256)  kubectl" | sha256sum --check
    - mv kubectl /usr/bin/ && chmod +x /usr/bin/kubectl
    - docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN https://$CI_REGISTRY
  script:
    - kubectl version --client
    - echo YAY!
    - docker pull ${IMAGE_NAME}:main
    #- kubectl --namespace kommul-dev set image deployment/merlin browser=${CONTAINER_IMAGE}:${CI_COMMIT_SHA}
  only:
    - main

.be-setup-job:
  image: node:16-alpine
  stage: setup
  cache:
    - key:
        files:
          - backend/package-lock.json
      paths:
        - backend/node_modules
  script:
    # TODO: drop python once we stop using sqlite3 in CI (soon, please)
    - apk add --update python2 build-base
    - cd backend
    - npm install
    - echo Success!