Commit 6928b109 authored by Tommy Svendsen's avatar Tommy Svendsen
Browse files

DEICH-4716 attempting to split docker-compose into several files for better readability

parent 5d9d2c08
image: frolvlad/alpine-glibc
variables:
DOCKERHUB_USERNAME: deichman
.before_script: &before
- echo -n "START :" && date -u +'%Y-%m-%dT%H:%M:%SZ'
- apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing make docker curl bash git
image: frolvlad/alpine-glibc
variables:
DOCKERHUB_USERNAME: deichman
.before_script: &before
- echo -n "START :" && date -u +'%Y-%m-%dT%H:%M:%SZ'
- apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing make docker curl bash git
- curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- echo $DOCKERHUB_PASSWORD|docker login -u $DOCKERHUB_USERNAME --password-stdin
- export DOCKER_BUILDKIT=1
- export COMPOSE_DOCKER_CLI_BUILD=1
- export TAG=${CI_COMMIT_TAG:-latest}
before_script:
- *before
stages:
- docker-cleanup
- test
- push
- deploy-test
- sanity
- deploy-stage
- deploy-prod
- patch
- patch-prod
include:
- "/gitlab-ci/push-jobs.yml"
- "/gitlab-ci/deploy-jobs.yml"
.ssh-setup:
before_script:
- apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing make docker curl bash git figlet
- curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- echo $DOCKERHUB_PASSWORD|docker login -u $DOCKERHUB_USERNAME --password-stdin
- export DOCKER_BUILDKIT=1
- export COMPOSE_DOCKER_CLI_BUILD=1
- export TAG=${CI_COMMIT_TAG:-latest}
.after_script: &after
- echo -n "END :" && date -u +'%Y-%m-%dT%H:%M:%SZ'
before_script:
- *before
- 'which ssh-agent || ( apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing openssh-client git )'
- eval $(ssh-agent -s)
- echo "$SSH_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- export APPLICATION_NAME=${APPLICATION_NAME}
e2e-tests:
tags:
- e2e
script:
- cd e2e-tests
- docker-compose -p $CI_PIPELINE_IID -f docker-compose-common.yml -f docker-compose-ci.yml up --build --exit-code-from tests
after_script:
- *after
stages:
- docker-cleanup
- build
- test
- push
- deploy-test
- sanity
- deploy-stage
- deploy-prod
#Building
.build-application:
script:
- echo -n "Building ${APPLICATION_NAME}"
- make build-${APPLICATION_NAME}
stage: build
except:
refs:
- tags
build-all:
stage: build
script:
- echo -n "Building all"
- make build-all
only:
refs:
- tags
# build-all-scheduled:
# stage: build
# script:
# - echo -n "Building all Scheduled"
# - make build-all
# only:
# variables:
# - $BUILD_TYPE == "scheduled"
build-authorization-server:
variables:
APPLICATION_NAME: authorization-server
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "authorization-server/**/*" ]
except:
refs:
- tags
build-deichman.no:
variables:
APPLICATION_NAME: deichman.no
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "deichman.no/**/*"]
build-elasticsearch:
variables:
APPLICATION_NAME: elasticsearch
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "elasticsearch/**/*"]
build-euler:
variables:
APPLICATION_NAME: euler
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "euler/**/*"]
build-f-users:
variables:
APPLICATION_NAME: f-users
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "f-users/**/*"]
build-image-api:
variables:
APPLICATION_NAME: image-api
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "image-api/**/*"]
build-image-cache:
variables:
APPLICATION_NAME: image-cache
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "image-cache/**/*"]
build-katalog:
variables:
APPLICATION_NAME: katalog
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "katalog/**/*"]
build-kibana:
variables:
APPLICATION_NAME: kibana
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "kibana/**/*"]
build-koha:
variables:
APPLICATION_NAME: koha
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "koha/**/*"]
build-mimir:
variables:
APPLICATION_NAME: mimir
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "mimir/**/*"]
build-redia-api:
variables:
APPLICATION_NAME: redia-api
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "redia-api/**/*"]
build-sibyl:
variables:
APPLICATION_NAME: sibyl
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "sibyl/**/*"]
build-skranke:
variables:
APPLICATION_NAME: skranke
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "skranke/**/*"]
build-test-ldap:
variables:
APPLICATION_NAME: test-ldap
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "test-ldap/**/*"]
build-tjenestekatalog:
variables:
APPLICATION_NAME: tjenestekatalog
extends:
- .build-application
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "tjenestekatalog/**/*"]
#Deployment
.deploy-scp:
before_script:
- *before
- apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing make curl bash git
- 'which ssh-agent || ( apk add --update --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing openssh-client git )'
- eval $(ssh-agent -s)
- echo "$SSH_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- export APPLICATION_NAME=${APPLICATION_NAME}
script:
- make remote-deploy-cold ssh_user=${SSH_USER} cold_node="${SSH_COLD_SERVER}"
- make remote-deploy ssh_user=${SSH_USER} ssh_servers="${SSH_SERVERS}" CONTAINER=${APPLICATION_NAME}
- make remote-deploy-voting ssh_user=${SSH_USER} voting_node="${SSH_VOTING_SERVER}"
when: manual
#Deploy test
.devtest:
stage: deploy-test
environment:
name: test
url: https://deichman.test.obib.no
variables:
SSH_USER: $DEPLOY_USER
SSH_SERVERS: $DEVTEST_SERVER
SSH_KNOWN_HOSTS: $DEVTEST_KNOWN_HOSTS
SSH_KEY: $DEPLOY_KEY
deploy-scheduled-test:
extends:
- .devtest
- .deploy-scp
after_script:
- ./transitionIssues.sh test
- *after
only:
variables:
- $BUILD_TYPE == "scheduled"
when: on_success
deploy-all-test:
extends:
- .devtest
- .deploy-scp
after_script:
- ./transitionIssues.sh test
- *after
when: manual
deploy-authorization-server-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: authorization-server
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "authorization-server/**/*"]
deploy-deichman_no-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: deichman.no
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "deichman.no/**/*"]
deploy-elasticsearch-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: elasticsearch
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "elasticsearch/**/*"]
deploy-euler-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: euler
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "euler/**/*"]
deploy-f-users-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: f-users
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "f-users/**/*"]
deploy-image-api-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: image-api
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "image-api/**/*"]
deploy-image-cache-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: image-cache
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "image-cache/**/*"]
deploy-katalog-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: katalog
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "katalog/**/*"]
deploy-kibana-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: kibana
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "kibana/**/*"]
deploy-koha-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: koha
after_script:
- *after
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "koha/**/*"]
deploy-mimir-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: mimir
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "mimir/**/*"]
deploy-redia-api-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: redia-api
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "redia-api/**/*"]
deploy-sibyl-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: sibyl
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "sibyl/**/*"]
deploy-skranke-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: skranke
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "skranke/**/*"]
deploy-test-ldap-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: test-ldap
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "test-ldap/**/*"]
deploy-tjenestekatalog-test:
extends:
- .devtest
- .deploy-scp
variables:
APPLICATION_NAME: tjenestekatalog
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "tjenestekatalog/**/*"]
#Deploy staging
.staging:
stage: deploy-stage
environment:
name: stage
url: https://staging.obib.no
variables:
SSH_USER: $DEPLOY_USER
SSH_KNOWN_HOSTS: $STAGING_HOSTS
SSH_SERVERS: "${STAGING_SERVERS}"
SSH_KEY: $DEPLOY_KEY
SSH_VOTING_SERVER: ${STAGING_VOTING_SERVER}
SSH_COLD_SERVER: ${STAGING_COLD_SERVER}
deploy-all-staging:
extends:
- .staging
- .deploy-scp
# only:
# refs:
# - tags
when: manual
after_script:
# - ./transitionIssues.sh stage
- *after
.production:
stage: deploy-prod
environment:
name: prod
url: https://beta.deichman.no
variables:
SSH_USER: $DEPLOY_USER
SSH_KNOWN_HOSTS: $PRODUCTION_HOSTS
SSH_SERVERS: "${PRODUCTION_SERVERS}"
SSH_KEY: $DEPLOY_KEY
SSH_VOTING_SERVER: ${PRODUCTION_VOTING_SERVER}
deploy-production:
extends:
- .production
- .deploy-scp
# only:
# refs:
# - tags
when: manual
after_script:
# - ./transitionIssues.sh stage
- *after
#Automated tests
koha-api-tests:
stage: sanity
extends:
- .devtest
variables:
DEVTEST_KOHA_DB: "koha-db"
DEVTEST_KOHA_API: "${DEVTEST_KOHA_API}"
#CMD: "'mysql -u $MYSQL_USER -p$MYSQL_PASSWORD koha_deichman' < /opt/deichman/deployment-config/koha/fixtures/cleanup.sql"
APPLICATION_NAME: koha
only:
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "koha/**/*"]
tags:
- koha
#before_script: # ensure clean slate
# - make remote-docker-command ssh_user=${SSH_USER} ssh_server="${SSH_SERVERS}" CONTAINER=${DEVTEST_KOHA_DB} cmd="${cmd}"
script:
- cd koha/tests
#- ./run_tests.sh
when: on_success
e2e-tests:
tags:
- e2e
script:
- cd e2e-tests
- docker-compose -p $CI_PIPELINE_IID -f docker-compose-common.yml -f docker-compose-ci.yml up --build --exit-code-from tests
after_script:
- cd e2e-tests
- docker-compose -p $CI_PIPELINE_IID -f docker-compose-common.yml -f docker-compose-ci.yml down -v --rmi local
- echo -n "END :" && date -u +'%Y-%m-%dT%H:%M:%SZ'
artifacts:
- cd e2e-tests
- docker-compose -p $CI_PIPELINE_IID -f docker-compose-common.yml -f docker-compose-ci.yml down -v --rmi local
- echo -n "END :" && date -u +'%Y-%m-%dT%H:%M:%SZ'
artifacts:
when: always
expire_in: 1 week
paths:
- e2e-tests/cypress/videos/
- e2e-tests/cypress/screenshots/
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: always
expire_in: 1 week
paths:
- e2e-tests/cypress/videos/
- e2e-tests/cypress/screenshots/
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: always
- when: manual
allow_failure: true
zork-cleanup:
stage: docker-cleanup
script:
- df -h /
- docker system df
- docker image prune -a -f # TODO: prune cache, volumes if necessary
- docker system df
- df -h /
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: always
- when: manual
allow_failure: true
#
## Push stages here
.push:
script:
- make push-${APPLICATION_NAME}
stage: push
except:
variables:
- $BUILD_TYPE == "scheduled"
refs:
- tags
when: manual
push-tag:
script:
- make push-all
stage: push
only:
refs:
- tags
push-authorization-server-latest:
extends:
- .push
when: on_success
variables:
APPLICATION_NAME: authorization-server
only:
refs:
- master
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "authorization-server/**/*"]
push-deichman.no-latest:
extends:
- .push
when: on_success
variables:
APPLICATION_NAME: deichman.no
only:
refs:
- master
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "deichman.no/**/*"]
push-elasticsearch-latest:
extends:
- .push
when: on_success
variables:
APPLICATION_NAME: elasticsearch
only:
refs:
- master
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "elasticsearch/**/*"]
push-euler-latest:
extends:
- .push
when: on_success
variables:
APPLICATION_NAME: euler
only:
refs:
- master
changes: [ "Makefile", ".gitlab-ci.yml", "*.sh", "euler/**/*"]
push-f-users-latest:
extends:
- .push
when: on_success
variables:
APPLICATION_NAME: f-users
only:
refs:
- master