stages:
- build
- deploy
services:
- docker:dind
build:
stage: build
image: docker:stable
before_script:
- docker login -u $GITLAB_USER_LOGIN -p $REGISTRY_TOKEN $CI_REGISTRY
script:
- docker build -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:nginx_app.$CI_PIPELINE_ID ./docker/nginx/app/
- docker build -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:nginx_open.$CI_PIPELINE_ID ./docker/nginx/open/
- docker build -t $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:app.$CI_PIPELINE_ID ./docker/php/
- docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:nginx_app.$CI_PIPELINE_ID
- docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:nginx_open.$CI_PIPELINE_ID
- docker push $CI_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:app.$CI_PIPELINE_ID
only:
- develop
deploy:
stage: deploy
image: docker/compose:1.27.4
variables:
DOCKER_HOST: tcp://84.201.160.194:2376
before_script:
- docker login -u $GITLAB_USER_LOGIN -p $REGISTRY_TOKEN $CI_REGISTRY
script:
- docker-compose -f docker-compose-ci.yml up -d
- docker-compose -f docker-compose-ci.yml exec app composer i --no-progress --no-suggest --no-interaction --quiet --no-scripts --prefer-dist
only:
- develop
stages:
- build
- deploy
build-dev:
image: node:latest
stage: build
script:
# Создаю тестовые файлы и каталоги
- mkdir build
- cd build
- touch TEST-1.MD
- touch TEST-2.MD
- mkdir one
- mkdir two
artifacts:
paths:
- build/ # В этой папке лежит мой артефакт
expire_in: 1 days
only:
- ci-test
# Развёртываю production на тестовом сервере (production for test)
deploy-dev:
stage: deploy
script:
- ssh-add <(echo "$STAGING_PRIVATE_KEY")
- ssh -p22 user@84.201.160.194 "sudo rm -R /var/www/admin/data/www/rmok.online/*"
- scp -P22 -r build/* user@84.201.160.194:/var/www/admin/data/www/rmok.online
artifacts:
paths:
- build/
only:
- ci-test