student life social platform

chore(ci): rewrite build and drop unused jobs build now use the docker job

+3
.gitignore
··· 50 50 51 51 # MacOS folder 52 52 .DS_Store 53 + 54 + # Ignore non-needed ci files 55 + !ci/build
+2 -4
.gitlab-ci.yml
··· 1 1 stages: 2 2 - changesets 3 - - build 4 3 - test 4 + - build 5 5 - deploy 6 6 7 7 include: 8 8 - ci/changesets.gitlab-ci.yml 9 9 - ci/volta.gitlab-ci.yml 10 - - ci/docker.gitlab-ci.yml 11 - # - ci/sast.gitlab-ci.yml 12 - # - ci/bot.gitlab-ci.yml 10 + - ci/build.gitlab-ci.yml
-11
ci/bot.gitlab-ci.yml
··· 1 - bot: 2 - rules: 3 - - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME 4 - stage: build # TODO move to stage: test when houdinification is complete 5 - image: 6 - name: harbor.k8s.inpt.fr/net7_public/churros-git-bot:latest 7 - entrypoint: 8 - - /usr/bin/env 9 - script: 10 - - cd /app 11 - - bundle exec churros_git_bot $CI_PROJECT_ID $CI_MERGE_REQUEST_IID $CI_PROJECT_URL
+36
ci/build.gitlab-ci.yml
··· 1 + .build: 2 + stage: build 3 + image: 4 + name: moby/buildkit:rootless 5 + entrypoint: ['sh', '-c'] 6 + variables: 7 + BUILDKITD_FLAGS: --oci-worker-no-process-sandbox 8 + # Default parameters 9 + TAG: export TAG=latest-$(date +%Y%m%d%H%m) 10 + DEPLOY: 'false' 11 + before_script: 12 + - mkdir ~/.docker 13 + - cp $HARBOR_CONFIG_JSON ~/.docker/config.json 14 + script: 15 + - eval $TAG 16 + - | 17 + buildctl-daemonless.sh build \ 18 + --frontend=dockerfile.v0 \ 19 + --local context=. \ 20 + --local dockerfile=. \ 21 + --opt target=$TARGET \ 22 + --opt build-arg:TAG=$TAG \ 23 + --secret id=SENTRY_AUTH_TOKEN \ 24 + --output type=image,name=$HARBOR_REGISTRY_IMAGE/$TARGET:v$TAG,push=$DEPLOY 25 + - | 26 + if [ "$DEPLOY" == "true" ]; then \ 27 + echo "Successfully built and pushed $HARBOR_REGISTRY_IMAGE/$TARGET:v$TAG"; \ 28 + else \ 29 + echo "Successfully built $HARBOR_REGISTRY_IMAGE/$TARGET:v$TAG"; \ 30 + fi 31 + 32 + include: 33 + - ci/build/api.gitlab-ci.yml 34 + - ci/build/app.gitlab-ci.yml 35 + - ci/build/db.gitlab-ci.yml 36 + - ci/build/sync.gitlab-ci.yml
+26
ci/build/api.gitlab-ci.yml
··· 1 + .api: 2 + extends: .build 3 + variables: 4 + TARGET: api 5 + 6 + build:api: 7 + extends: .api 8 + stage: build 9 + rules: 10 + - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE !~ /^(\[Draft\]|\(Draft\)|Draft:)/ 11 + - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ 12 + when: manual 13 + 14 + deploy:api: 15 + extends: .api 16 + stage: deploy 17 + rules: 18 + - if: $CI_COMMIT_TAG =~ /^@churros\/api@(\d+\.\d+\.\d+)/ 19 + variables: 20 + ENV: "production" 21 + URL: "https://churros.inpt.fr" 22 + TAG: export TAG=$(echo $CI_COMMIT_TAG | sed 's/@churros\/api@//') 23 + DEPLOY: "true" 24 + environment: 25 + name: $ENV 26 + url: $URL
+26
ci/build/app.gitlab-ci.yml
··· 1 + .app: 2 + extends: .build 3 + variables: 4 + TARGET: app 5 + 6 + build:app: 7 + extends: .app 8 + stage: build 9 + rules: 10 + - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE !~ /^(\[Draft\]|\(Draft\)|Draft:)/ 11 + - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ 12 + when: manual 13 + 14 + deploy:app: 15 + extends: .app 16 + stage: deploy 17 + rules: 18 + - if: $CI_COMMIT_TAG =~ /^@churros\/app@(\d+\.\d+\.\d+)/ 19 + variables: 20 + ENV: "production" 21 + URL: "https://churros.inpt.fr" 22 + TAG: export TAG=$(echo $CI_COMMIT_TAG | sed 's/@churros\/app@//') 23 + DEPLOY: "true" 24 + environment: 25 + name: $ENV 26 + url: $URL
+26
ci/build/db.gitlab-ci.yml
··· 1 + .prisma: 2 + extends: .build 3 + variables: 4 + TARGET: prisma 5 + 6 + build:prisma: 7 + extends: .prisma 8 + stage: build 9 + rules: 10 + - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE !~ /^(\[Draft\]|\(Draft\)|Draft:)/ 11 + - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ 12 + when: manual 13 + 14 + deploy:prisma: 15 + extends: .prisma 16 + stage: deploy 17 + rules: 18 + - if: $CI_COMMIT_TAG =~ /^@churros\/db@(\d+\.\d+\.\d+)/ 19 + variables: 20 + ENV: "production" 21 + URL: "https://churros.inpt.fr" 22 + TAG: export TAG=$(echo $CI_COMMIT_TAG | sed 's/@churros\/db@//') 23 + DEPLOY: "true" 24 + environment: 25 + name: $ENV 26 + url: $URL
+26
ci/build/sync.gitlab-ci.yml
··· 1 + .sync: 2 + extends: .build 3 + variables: 4 + TARGET: sync 5 + 6 + build:sync: 7 + extends: .sync 8 + stage: build 9 + rules: 10 + - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE !~ /^(\[Draft\]|\(Draft\)|Draft:)/ 11 + - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(\[Draft\]|\(Draft\)|Draft:)/ 12 + when: manual 13 + 14 + deploy:sync: 15 + extends: .sync 16 + stage: deploy 17 + rules: 18 + - if: $CI_COMMIT_TAG =~ /^@churros\/sync@(\d+\.\d+\.\d+)/ 19 + variables: 20 + ENV: "production" 21 + URL: "https://churros.inpt.fr" 22 + TAG: export TAG=$(echo $CI_COMMIT_TAG | sed 's/@churros\/sync@//') 23 + DEPLOY: "true" 24 + environment: 25 + name: $ENV 26 + url: $URL
-81
ci/docker.gitlab-ci.yml
··· 1 - .buildkit: 2 - image: 3 - name: moby/buildkit:rootless 4 - entrypoint: ['sh', '-c'] 5 - variables: 6 - BUILDKITD_FLAGS: --oci-worker-no-process-sandbox 7 - before_script: 8 - - mkdir ~/.docker 9 - - cp $HARBOR_CONFIG_JSON ~/.docker/config.json 10 - 11 - deploy_prisma: 12 - extends: .buildkit 13 - stage: deploy 14 - rules: 15 - - if: $CI_COMMIT_TAG =~ /^@churros\/db@(\d+\.\d+\.\d+)/ 16 - script: 17 - - export TAG=$(echo $CI_COMMIT_TAG | sed 's/@churros\/db@//') 18 - - | 19 - buildctl-daemonless.sh build \ 20 - --frontend=dockerfile.v0 \ 21 - --local context=. \ 22 - --local dockerfile=. \ 23 - --opt target=prisma \ 24 - --opt build-arg:TAG=$TAG \ 25 - --output type=image,name=$HARBOR_REGISTRY_IMAGE/prisma:v$TAG,push=true 26 - - echo "Successfully built and pushed $HARBOR_REGISTRY_IMAGE/prisma:v$TAG" 27 - 28 - deploy_api: 29 - extends: .buildkit 30 - stage: deploy 31 - rules: 32 - - if: $CI_COMMIT_TAG =~ /^@churros\/api@(\d+\.\d+\.\d+)/ 33 - script: 34 - - export TAG=$(echo $CI_COMMIT_TAG | sed 's/@churros\/api@//') 35 - - | 36 - buildctl-daemonless.sh build \ 37 - --frontend=dockerfile.v0 \ 38 - --local context=. \ 39 - --local dockerfile=. \ 40 - --opt target=api \ 41 - --secret id=SENTRY_AUTH_TOKEN \ 42 - --output type=image,name=$HARBOR_REGISTRY_IMAGE/api:v$TAG,push=true 43 - - echo "Successfully built and pushed $HARBOR_REGISTRY_IMAGE/api:v$TAG" 44 - 45 - deploy_app: 46 - extends: .buildkit 47 - stage: deploy 48 - variables: 49 - SENTRY_PROJECT: app 50 - rules: 51 - - if: $CI_COMMIT_TAG =~ /^@churros\/app@(\d+\.\d+\.\d+)/ 52 - script: 53 - - export TAG=$(echo $CI_COMMIT_TAG | sed 's/@churros\/app@//') 54 - - | 55 - buildctl-daemonless.sh build \ 56 - --frontend=dockerfile.v0 \ 57 - --local context=. \ 58 - --local dockerfile=. \ 59 - --opt target=app \ 60 - --opt build-arg:TAG=$TAG \ 61 - --secret id=SENTRY_AUTH_TOKEN \ 62 - --output type=image,name=$HARBOR_REGISTRY_IMAGE/app:v$TAG,push=true 63 - - echo "Successfully built and pushed $HARBOR_REGISTRY_IMAGE/app:v$TAG" 64 - 65 - deploy_sync: 66 - extends: .buildkit 67 - stage: deploy 68 - rules: 69 - - if: $CI_COMMIT_TAG =~ /^@churros\/sync@(\d+\.\d+\.\d+)/ 70 - script: 71 - - export TAG=$(echo $CI_COMMIT_TAG | sed 's/@churros\/sync@//') 72 - - | 73 - buildctl-daemonless.sh build \ 74 - --frontend=dockerfile.v0 \ 75 - --local context=. \ 76 - --local dockerfile=. \ 77 - --opt target=sync \ 78 - --opt build-arg:TAG=$TAG \ 79 - --secret id=SENTRY_AUTH_TOKEN \ 80 - --output type=image,name=$HARBOR_REGISTRY_IMAGE/sync:v$TAG,push=true 81 - - echo "Successfully built and pushed $HARBOR_REGISTRY_IMAGE/sync:v$TAG"
-19
ci/volta.gitlab-ci.yml
··· 13 13 paths: 14 14 - .yarn/cache/ 15 15 16 - build: 17 - stage: build 18 - extends: .volta 19 - rules: 20 - # wishing that gilab adds $CI_MERGE_REQUEST_DRAFT one day... 21 - - if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME && $CI_MERGE_REQUEST_TITLE !~ /^Draft: /' 22 - # still allow to run the build job on the pipeline on Draft MRs, but only when we actually want to (manual action) 23 - - if: '$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME && $CI_MERGE_REQUEST_TITLE =~ /^Draft: /' 24 - when: manual 25 - # prevents branch pipeline when a merge request pipeline will be created, see https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines 26 - - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push" 27 - when: never 28 - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH 29 - when: manual 30 - script: 31 - - export SENTRY_AUTH_TOKEN='' 32 - - yarn prisma generate 33 - - yarn build 34 - 35 16 pages: 36 17 stage: deploy 37 18 extends: .volta