ci: change ci file and move build stage on separate server

This commit is contained in:
skeris 2024-01-10 21:55:39 +03:00
parent 2489fbec59
commit 096da6be46
2 changed files with 17 additions and 29 deletions

@ -1,12 +1,16 @@
include:
- project: "devops/pena-continuous-integration"
file: "/templates/docker/build-template.gitlab-ci.yml"
- project: "devops/pena-continuous-integration"
file: "/templates/docker/deploy-template.gitlab-ci.yml"
stages: stages:
- build - build
- deploy - deploy
build-app: build-app:
stage: build stage: build
image: tags:
name: gcr.io/kaniko-project/executor:debug - gobuild
entrypoint: [""]
variables: variables:
DOCKER_BUILD_PATH: "./Dockerfile" DOCKER_BUILD_PATH: "./Dockerfile"
STAGING_BRANCH: "staging" STAGING_BRANCH: "staging"
@ -24,32 +28,21 @@ build-app:
- echo CI_COMMIT_REF_SLUG = $CI_COMMIT_REF_SLUG - echo CI_COMMIT_REF_SLUG = $CI_COMMIT_REF_SLUG
- echo DOCKER_BUILD_PATH = $DOCKER_BUILD_PATH - echo DOCKER_BUILD_PATH = $DOCKER_BUILD_PATH
- echo CI_PIPELINE_ID = $CI_PIPELINE_ID - echo CI_PIPELINE_ID = $CI_PIPELINE_ID
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script: script:
- mkdir -p /kaniko/.docker - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID --build-arg GITLAB_TOKEN=$GITLAB_TOKEN $CI_PROJECT_DIR
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
- |
/kaniko/executor --context $CI_PROJECT_DIR \
--cache=true --cache-repo=$CI_REGISTRY_IMAGE \
--dockerfile $CI_PROJECT_DIR/$DOCKER_BUILD_PATH --target production \
--destination $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG.$CI_PIPELINE_ID
deploy-to-staging: deploy-to-staging:
stage: deploy stage: deploy
image: extends: .deploy_template
name: docker/compose:1.28.0
entrypoint: [""]
variables: variables:
DEPLOY_TO: "staging" DEPLOY_TO: "staging"
BRANCH: "staging" BRANCH: "staging"
rules: rules:
- if: $CI_COMMIT_BRANCH == $BRANCH - if: "$CI_COMMIT_BRANCH == $BRANCH"
before_script:
- echo CI_PROJECT_NAME = $CI_PROJECT_NAME
- echo CI_REGISTRY = $CI_REGISTRY
- echo REGISTRY_USER = $REGISTRY_USER
- echo REGISTRY_TOKEN = $REGISTRY_TOKEN
- echo DEPLOY_TO = $DEPLOY_TO
- echo BRANCH = $BRANCH
script:
- docker login -u $REGISTRY_USER -p $REGISTRY_TOKEN $CI_REGISTRY
- docker-compose -f deployments/$DEPLOY_TO/docker-compose.yaml up -d

@ -37,9 +37,4 @@ services:
- 8065:8065 - 8065:8065
- 9065:9065 - 9065:9065
networks: networks:
- marketplace_penahub_frontend
- default - default
networks:
marketplace_penahub_frontend:
external: true