320 lines
No EOL
8.2 KiB
YAML
320 lines
No EOL
8.2 KiB
YAML
stages:
|
|
- dependencies
|
|
- test
|
|
- setup
|
|
- build
|
|
- staging
|
|
- release
|
|
- deploy
|
|
|
|
dependencies:production:
|
|
image: node:$NODE_VERSION
|
|
stage: dependencies
|
|
only:
|
|
refs:
|
|
- master
|
|
before_script:
|
|
- npm -g config set user root
|
|
script:
|
|
- npm ci
|
|
cache:
|
|
key:
|
|
files:
|
|
- package-lock.json
|
|
paths:
|
|
- node_modules
|
|
artifacts:
|
|
expire_in: 1 hour
|
|
paths:
|
|
- node_modules/
|
|
|
|
test:
|
|
image: node:$NODE_VERSION
|
|
stage: setup
|
|
dependencies:
|
|
- dependencies:production
|
|
only:
|
|
- master
|
|
before_script:
|
|
- npm run lint
|
|
script:
|
|
- CI=true npm run test
|
|
|
|
setup:production:
|
|
image: node:$NODE_VERSION
|
|
stage: setup
|
|
dependencies:
|
|
- dependencies:production
|
|
only:
|
|
- master
|
|
script:
|
|
- npm run build:production
|
|
artifacts:
|
|
expire_in: 1 hour
|
|
paths:
|
|
- build
|
|
|
|
build:production:
|
|
image: docker:20.10.21
|
|
stage: build
|
|
dependencies:
|
|
- setup:production
|
|
variables:
|
|
DOCKER_DRIVER: overlay2
|
|
DOCKER_TLS_CERTDIR: ""
|
|
services:
|
|
- docker:20.10.21-dind
|
|
only:
|
|
- master
|
|
before_script:
|
|
- docker login -u ${CI_REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
|
|
script:
|
|
- docker build -t ${CI_REGISTRY}/brandx/frontend/production:${CI_COMMIT_SHA} .
|
|
- docker tag ${CI_REGISTRY}/brandx/frontend/production:${CI_COMMIT_SHA} ${CI_REGISTRY}/brandx/frontend/production:latest
|
|
- docker push ${CI_REGISTRY}/brandx/frontend/production
|
|
|
|
deploy:production:
|
|
image: docker:20.10.21
|
|
stage: deploy
|
|
variables:
|
|
DOCKER_DRIVER: overlay2
|
|
DOCKER_HOST: ssh://deploy@bxt-prod01.brandxtech.ca
|
|
DEPLOY_IMAGE: ${CI_REGISTRY}/brandx/frontend/production:latest
|
|
DEPLOY_TARGET: deploy@bxt-prod01.brandxtech.ca
|
|
only:
|
|
- master
|
|
environment:
|
|
name: Production
|
|
url: https://dashboard.adaptiveagriculture.ca
|
|
before_script: &deploy_tunnel
|
|
- "apk --update add openssh-client"
|
|
- "eval $(ssh-agent -s)"
|
|
- "echo \"$DEPLOY_SSH_PRIV_KEY\" | tr -d '\r' | ssh-add - > /dev/null"
|
|
# - "ssh -Mo StrictHostKeyChecking=no -S deploy-ctrl-socket -fnNTL /var/run/docker.sock:/var/run/docker.sock ${DEPLOY_TARGET}"
|
|
# - "ssh -S deploy-ctrl-socket -O check ${DEPLOY_TARGET}"
|
|
- mkdir -p ~/.ssh
|
|
- chmod 700 ~/.ssh
|
|
- ssh -o StrictHostKeyChecking=no ${DEPLOY_TARGET}
|
|
script:
|
|
- docker login -u ${CI_REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
|
|
- docker stack deploy --with-registry-auth -c docker-compose.yml webui
|
|
when: manual
|
|
allow_failure: false
|
|
|
|
dependencies:staging:
|
|
image: node:$NODE_VERSION
|
|
stage: dependencies
|
|
only:
|
|
refs:
|
|
- staging_environment
|
|
before_script:
|
|
- npm -g config set user root
|
|
script:
|
|
- npm ci
|
|
cache:
|
|
key:
|
|
files:
|
|
- package-lock.json
|
|
paths:
|
|
- node_modules
|
|
artifacts:
|
|
expire_in: 1 hour
|
|
paths:
|
|
- node_modules/
|
|
|
|
test:staging:
|
|
image: node:$NODE_VERSION
|
|
stage: setup
|
|
dependencies:
|
|
- dependencies:staging
|
|
only:
|
|
- staging_environment
|
|
before_script:
|
|
- npm run lint
|
|
script:
|
|
- CI=true npm run test
|
|
|
|
setup:staging:
|
|
image: node:$NODE_VERSION
|
|
stage: setup
|
|
dependencies:
|
|
- dependencies:staging
|
|
only:
|
|
- staging_environment
|
|
script:
|
|
- npm run build:staging
|
|
artifacts:
|
|
expire_in: 1 hour
|
|
paths:
|
|
- build
|
|
|
|
build:base:
|
|
image: docker:20.10.21
|
|
stage: build
|
|
dependencies:
|
|
- dependencies:staging
|
|
variables:
|
|
DOCKER_DRIVER: overlay2
|
|
PROJECT: brandx/frontend
|
|
DOCKER_TLS_CERTDIR: ""
|
|
services:
|
|
- docker:20.10.21-dind
|
|
only:
|
|
- master
|
|
before_script:
|
|
- docker login -u ${CI_REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
|
|
script:
|
|
- docker build -t ${CI_REGISTRY}/${PROJECT}/base:${CI_COMMIT_SHA} -f Dockerfile.base .
|
|
- docker tag ${CI_REGISTRY}/${PROJECT}/base:${CI_COMMIT_SHA} ${CI_REGISTRY}/${PROJECT}/base:staging
|
|
- docker push ${CI_REGISTRY}/${PROJECT}/base
|
|
when: manual
|
|
allow_failure: true
|
|
|
|
build:staging:
|
|
image: docker:20.10.21
|
|
stage: build
|
|
dependencies:
|
|
- setup:staging
|
|
variables:
|
|
DOCKER_DRIVER: overlay2
|
|
DOCKER_TLS_CERTDIR: ""
|
|
services:
|
|
- docker:20.10.21-dind
|
|
only:
|
|
- staging_environment
|
|
before_script:
|
|
- docker login -u ${CI_REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
|
|
script:
|
|
- docker build -t ${CI_REGISTRY}/brandx/frontend/production:${CI_COMMIT_SHA} .
|
|
- docker tag ${CI_REGISTRY}/brandx/frontend/production:${CI_COMMIT_SHA} ${CI_REGISTRY}/brandx/frontend/production:staging
|
|
- docker push ${CI_REGISTRY}/brandx/frontend/production:staging
|
|
|
|
staging:deploy:
|
|
image: docker:20.10.21
|
|
stage: staging
|
|
variables:
|
|
DOCKER_DRIVER: overlay2
|
|
DEPLOY_IMAGE: ${CI_REGISTRY}/brandx/frontend/production:staging
|
|
DOCKER_HOST: ssh://deploy@staging.brandxtech.ca
|
|
DEPLOY_TARGET: deploy@staging.brandxtech.ca
|
|
only:
|
|
- staging_environment
|
|
environment:
|
|
name: Staging
|
|
url: https://staging.brandxtech.ca
|
|
before_script: &staging_tunnel
|
|
- "apk --update add openssh-client"
|
|
- "eval $(ssh-agent -s)"
|
|
- "echo \"$STAGING_SSH_PRIV_KEY\" | tr -d '\r' | ssh-add - > /dev/null"
|
|
# - "ssh -Mo StrictHostKeyChecking=no -S deploy-ctrl-socket -fnNTL /var/run/docker.sock:/var/run/docker.sock ${DEPLOY_TARGET}"
|
|
# - "ssh -S deploy-ctrl-socket -O check ${DEPLOY_TARGET}"
|
|
- mkdir -p ~/.ssh
|
|
- chmod 700 ~/.ssh
|
|
- ssh -o StrictHostKeyChecking=no ${DEPLOY_TARGET}
|
|
script:
|
|
- docker login -u ${CI_REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
|
|
- docker stack deploy --with-registry-auth -c docker-compose.staging.yml webui
|
|
when: manual
|
|
allow_failure: false
|
|
|
|
dependencies:development:
|
|
image: node:$NODE_VERSION
|
|
stage: dependencies
|
|
only:
|
|
refs:
|
|
- dev_environment
|
|
before_script:
|
|
- npm -g config set user root
|
|
script:
|
|
- npm ci
|
|
cache:
|
|
key:
|
|
files:
|
|
- package-lock.json
|
|
paths:
|
|
- node_modules
|
|
artifacts:
|
|
expire_in: 1 hour
|
|
paths:
|
|
- node_modules/
|
|
|
|
test:development:
|
|
image: node:$NODE_VERSION
|
|
stage: setup
|
|
dependencies:
|
|
- dependencies:development
|
|
only:
|
|
- dev_environment
|
|
before_script:
|
|
- npm run lint
|
|
script:
|
|
- CI=true npm run test
|
|
|
|
setup:development:
|
|
image: node:$NODE_VERSION
|
|
stage: setup
|
|
dependencies:
|
|
- dependencies:development
|
|
only:
|
|
- dev_environment
|
|
script:
|
|
- npm run build:development
|
|
artifacts:
|
|
expire_in: 1 hour
|
|
paths:
|
|
- build
|
|
|
|
build:development:
|
|
image: docker:20.10.21
|
|
stage: build
|
|
dependencies:
|
|
- setup:development
|
|
variables:
|
|
DOCKER_DRIVER: overlay2
|
|
DOCKER_TLS_CERTDIR: ""
|
|
services:
|
|
- docker:20.10.21-dind
|
|
only:
|
|
- dev_environment
|
|
before_script:
|
|
- docker login -u ${CI_REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
|
|
script:
|
|
- docker build -t ${CI_REGISTRY}/brandx/frontend/production:${CI_COMMIT_SHA} .
|
|
- docker tag ${CI_REGISTRY}/brandx/frontend/production:${CI_COMMIT_SHA} ${CI_REGISTRY}/brandx/frontend/production:development
|
|
- docker push ${CI_REGISTRY}/brandx/frontend/production:development
|
|
|
|
deploy:development:
|
|
image: docker:20.10.21
|
|
stage: deploy
|
|
variables:
|
|
DOCKER_DRIVER: overlay2
|
|
DEPLOY_IMAGE: ${CI_REGISTRY}/brandx/frontend/production:development
|
|
DOCKER_HOST: ssh://deploy@bxt-dev.adaptiveagriculture.ca
|
|
DEPLOY_TARGET: deploy@bxt-dev.adaptiveagriculture.ca
|
|
only:
|
|
- dev_environment
|
|
environment:
|
|
name: Development
|
|
url: https://bxt-dev.adaptiveagriculture.ca
|
|
before_script: &dev_tunnel
|
|
- "apk --update add openssh-client"
|
|
- "eval $(ssh-agent -s)"
|
|
- ssh -V
|
|
- cat /etc/os-release
|
|
- "echo DEPLOY_TARGET=${DEPLOY_TARGET}"
|
|
- "echo DOCKER_HOST=${DOCKER_HOST}"
|
|
- "echo \"Dev Key length: ${#DEVELOPMENT_SSH_PRIV_KEY}\""
|
|
# - "echo \"Staging Key length: ${#STAGING_SSH_PRIV_KEY}\""
|
|
# - "echo \"$STAGING_SSH_PRIV_KEY\" | tr -d '\r' | ssh-add - > /dev/null"
|
|
- "echo \"$DEVELOPMENT_SSH_PRIV_KEY\" | tr -d '\r' | ssh-add - "
|
|
# - "ssh -Mo StrictHostKeyChecking=no -S deploy-ctrl-socket -fnNTL /var/run/docker.sock:/var/run/docker.sock ${DEPLOY_TARGET}"
|
|
# - "ssh -S deploy-ctrl-socket -O check ${DEPLOY_TARGET}"
|
|
- mkdir -p ~/.ssh
|
|
- chmod 700 ~/.ssh
|
|
- ssh -o StrictHostKeyChecking=no ${DEPLOY_TARGET}
|
|
script:
|
|
- docker login -u ${CI_REGISTRY_USER} -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
|
|
- docker stack deploy --with-registry-auth -c docker-compose.dev.yml webui
|
|
when: manual
|
|
allow_failure: false
|
|
|