add universal pipeline

This commit is contained in:
kandrusyak
2023-07-04 00:37:35 +03:00
parent 64b81de96d
commit a015f8f9b1
3 changed files with 58 additions and 57 deletions

View File

@@ -1,57 +1,40 @@
image: docker:20.10.16 image: docker:20.10.16
variables: variables:
# When using dind service, you must instruct Docker to talk with DOCKER_HOST: tcp://docker:2376
# the daemon started inside of the service. The daemon is available DOCKER_TLS_CERTDIR: "/certs"
# with a network connection instead of the default DOCKER_TLS_VERIFY: 1
# /var/run/docker.sock socket. DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
DOCKER_HOST: tcp://docker:2376
# services:
# The 'docker' hostname is the alias of the service container as described at - docker:20.10.16-dind
# https://docs.gitlab.com/ee/ci/services/#accessing-the-services.
# If you're using GitLab Runner 12.7 or earlier with the Kubernetes executor and Kubernetes 1.6 or earlier, stages:
# the variable must be set to tcp://localhost:2376 because of how the - build
# Kubernetes executor connects services to the job container - deploy
# DOCKER_HOST: tcp://localhost:2376
# build-job:
# Specify to Docker where to create the certificates. Docker stage: build
# creates them automatically on boot, and creates tags:
# `/certs/client` to share between the service and job - docker
# container, thanks to volume mount from config.toml only:
DOCKER_TLS_CERTDIR: "/certs" - master
# These are usually specified by the entrypoint, however the script:
# Kubernetes executor doesn't run entrypoints - docker info
# https://gitlab.com/gitlab-org/gitlab-runner/-/issues/4125 - docker build -t docker-registry.dopcore.com/$CI_PROJECT_PATH .
DOCKER_TLS_VERIFY: 1 - echo "$CI_REGISTRY_PASSWORD" | docker login docker-registry.dopcore.com -u "$CI_REGISTRY_USER" --password-stdin
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" - docker push docker-registry.dopcore.com/$CI_PROJECT_PATH
services: deploy-job:
- docker:20.10.16-dind stage: deploy
image: dtzar/helm-kubectl:latest
stages: tags:
- build - docker
- deploy only:
- master
build-job: script:
stage: build - export $(xargs < deploy/.env)
tags: - envsubst < deploy/values.template.yaml > deploy/values.yaml
- docker - kubectl version
only: - helm upgrade --install $CI_PROJECT_TITLE deploy
- master - kubectl rollout restart deploy/$CI_PROJECT_TITLE
script:
- docker info
- docker build -t docker-registry.dopcore.com/andrusyakka/astra-file-storage .
- echo "$DOCKER_PASSWORD" | docker login docker-registry.dopcore.com -u "$DOCKER_USER" --password-stdin
- docker push docker-registry.dopcore.com/andrusyakka/astra-file-storage
deploy-job:
stage: deploy
image: dtzar/helm-kubectl:latest
tags:
- docker
only:
- master
script:
- kubectl version
- helm upgrade --install astra-file-storage deploy
- kubectl rollout restart deploy/astra-file-storage

2
deploy/.env Normal file
View File

@@ -0,0 +1,2 @@
SERVICE_REPLICAS=3
SERVICE_PORT=8080

View File

@@ -0,0 +1,16 @@
app:
fullName: ${CI_PROJECT_TITLE}
image: docker-registry.dopcore.com/${CI_PROJECT_PATH}
server:
port: ${SERVICE_PORT}
replicas: ${SERVICE_REPLICAS}
images:
pullSecret: regcred
ingress:
enabled: false
autoscaling:
enabled: false