Files
gitlab-ci/ci/.gitlab-ci.yml
2022-09-07 10:05:29 +07:00

45 lines
1.3 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# полный реферерс тут
# https://docs.gitlab.com/ee/ci/yaml/index.html
# а тут доступные переменные
# https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
image: docker:20.10.16
variables:
REGISTRY: hub.bildme.ru
IMAGE_NAME: $REGISTRY/$CI_PROJECT_PATH:latest
VERSION: 0.0.1
stages:
- build
- deploy
build_main:
stage: build
variables:
DOCKER_BASEIMAGE: golang:latest
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $REGISTRY
script:
- docker build --pull --build-arg DOCKER_BASEIMAGE=${DOCKER_BASEIMAGE} -build-arg VERSION=${VERSION} -t $IMAGE_NAME .
- docker push $IMAGE_NAME
tags:
- docker
deploy_prod:
image: hub.realmanual.ru/pub/openssh-client:latest
stage: deploy
variables:
DOCKER_SERVER: 192.168.9.199
before_script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan ${DOCKER_SERVER} >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh root@${DOCKER_SERVER} "docker rm -f main-go; docker pull hub.bildme.ru/firstgroup/go-site && docker run --rm --name main-go -p 3000:3000 hub.bildme.ru/firstgroup/go-site:latest"
tags:
- docker