Commit 80d220cf authored by Matija Obreza's avatar Matija Obreza

Automatically deploy branches to Docker

parent 73299961
...@@ -4,22 +4,22 @@ variables: ...@@ -4,22 +4,22 @@ variables:
DOCKER_VERSION: latest DOCKER_VERSION: latest
stages: stages:
- compile # - compile
- package - package
- dockerize - dockerize
- deploy - deploy
compile and test: # compile and test:
stage: compile # stage: compile
image: dockerhub.croptrust.org/docker/custom/maven-with-compass:latest # image: dockerhub.croptrust.org/docker/custom/maven-with-compass:latest
except: # except:
- master # - master
- production # - production
- tags # - tags
script: # script:
- echo "CI_COMMIT_REF_SLUG ${CI_COMMIT_REF_SLUG}" # - echo "CI_COMMIT_REF_SLUG ${CI_COMMIT_REF_SLUG}"
- echo "CI_ENVIRONMENT_SLUG ${CI_ENVIRONMENT_SLUG}" # - echo "CI_ENVIRONMENT_SLUG ${CI_ENVIRONMENT_SLUG}"
- MAVEN_OPTS="${MAVEN_OPTS} -Dorg.slf4j.simpleLogger.defaultLogLevel=warn" mvn compile test -B -U # - MAVEN_OPTS="${MAVEN_OPTS} -Dorg.slf4j.simpleLogger.defaultLogLevel=warn" mvn compile test -B -U
.package_template: &maven_package .package_template: &maven_package
image: dockerhub.croptrust.org/docker/custom/maven-with-compass:latest image: dockerhub.croptrust.org/docker/custom/maven-with-compass:latest
...@@ -42,7 +42,7 @@ package genesys: ...@@ -42,7 +42,7 @@ package genesys:
package genesys branch: package genesys branch:
<<: *maven_package <<: *maven_package
stage: package stage: package
when: manual # when: manual
allow_failure: false allow_failure: false
except: except:
- master - master
...@@ -53,10 +53,9 @@ package genesys branch: ...@@ -53,10 +53,9 @@ package genesys branch:
.docker_image_template: &docker_image .docker_image_template: &docker_image
image: docker:${DOCKER_VERSION} image: docker:${DOCKER_VERSION}
before_script: before_script:
# Configuration
- echo Building docker image ${CI_REGISTRY_IMAGE} on ${DOCKER_HOST} - echo Building docker image ${CI_REGISTRY_IMAGE} on ${DOCKER_HOST}
- echo Registry ${CI_REGISTRY} user=${CI_REGISTRY_USER} ${CI_REGISTRY_PASSWORD} - echo Registry ${CI_REGISTRY} user=${CI_REGISTRY_USER} ${CI_REGISTRY_PASSWORD}
script:
# Configuration
- TLS_PATH=~/.docker/${DOCKER_HOST}/certs && mkdir -p ${TLS_PATH} - TLS_PATH=~/.docker/${DOCKER_HOST}/certs && mkdir -p ${TLS_PATH}
- echo "${DOCKER_TLS_CA}" > ${TLS_PATH}/ca.pem - echo "${DOCKER_TLS_CA}" > ${TLS_PATH}/ca.pem
- echo "${DOCKER_TLS_KEY}" > ${TLS_PATH}/key.pem - echo "${DOCKER_TLS_KEY}" > ${TLS_PATH}/key.pem
...@@ -64,8 +63,7 @@ package genesys branch: ...@@ -64,8 +63,7 @@ package genesys branch:
- export DOCKER_TLS_VERIFY=1 - export DOCKER_TLS_VERIFY=1
- export DOCKER_CERT_PATH=${TLS_PATH} - export DOCKER_CERT_PATH=${TLS_PATH}
- DOCKER_CMD="docker --tlsverify=false" - DOCKER_CMD="docker --tlsverify=false"
# - ls -la ${DOCKER_CERT_PATH} script:
# - set | grep DOCKER
# Actions # Actions
- cp target/*.war docker - cp target/*.war docker
- cd docker - cd docker
...@@ -112,8 +110,8 @@ deploy for review: ...@@ -112,8 +110,8 @@ deploy for review:
# when: manual # when: manual
allow_failure: false allow_failure: false
environment: environment:
name: review/$CI_COMMIT_REF_SLUG name: genesys/${CI_COMMIT_REF_SLUG}
url: https://${CI_COMMIT_REF_SLUG}.review.genesys-pgr.org url: https://${CI_ENVIRONMENT_SLUG}.review.genesys-pgr.org
on_stop: remove review instance on_stop: remove review instance
script: script:
# Address the swarm # Address the swarm
...@@ -133,11 +131,11 @@ deploy for review: ...@@ -133,11 +131,11 @@ deploy for review:
else else
export IMAGE_TAG="${GENESYS_VERSION}-${CI_COMMIT_REF_SLUG}"; export IMAGE_TAG="${GENESYS_VERSION}-${CI_COMMIT_REF_SLUG}";
fi fi
- echo Deploying ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} for review as https\://${CI_COMMIT_REF_SLUG}.review.genesys\-pgr.org - echo Deploying ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} for review as https\://${CI_ENVIRONMENT_SLUG}.review.genesys\-pgr.org
- envsubst < docker/review-compose-template.yml > review-composed.yml - envsubst < docker/review-compose-template.yml > review-composed.yml
- cat review-composed.yml - cat review-composed.yml
- ${DOCKER_CMD} stack rm genesys-${CI_COMMIT_REF_SLUG}-review || true - ${DOCKER_CMD} stack rm ${CI_ENVIRONMENT_SLUG} || true
- ${DOCKER_CMD} stack deploy -c review-composed.yml genesys-${CI_COMMIT_REF_SLUG}-review - ${DOCKER_CMD} stack deploy -c review-composed.yml ${CI_ENVIRONMENT_SLUG}
remove review instance: remove review instance:
stage: deploy stage: deploy
...@@ -149,10 +147,10 @@ remove review instance: ...@@ -149,10 +147,10 @@ remove review instance:
variables: variables:
GIT_STRATEGY: none GIT_STRATEGY: none
environment: environment:
name: review/$CI_COMMIT_REF_SLUG name: genesys/${CI_COMMIT_REF_SLUG}
action: stop action: stop
script: script:
- echo Removing review https\://${CI_COMMIT_REF_SLUG}.review.genesys\-pgr.org - echo Removing review https\://${CI_ENVIRONMENT_SLUG}.review.genesys\-pgr.org
# Address the swarm # Address the swarm
- export DOCKER_HOST=swarm.genesys-pgr.org - export DOCKER_HOST=swarm.genesys-pgr.org
# Configuration # Configuration
...@@ -164,7 +162,7 @@ remove review instance: ...@@ -164,7 +162,7 @@ remove review instance:
- export DOCKER_CERT_PATH=${TLS_PATH} - export DOCKER_CERT_PATH=${TLS_PATH}
- DOCKER_CMD=docker - DOCKER_CMD=docker
# Actions # Actions
- ${DOCKER_CMD} stack rm genesys-${CI_COMMIT_REF_SLUG}-review || true - ${DOCKER_CMD} stack rm ${CI_ENVIRONMENT_SLUG} || true
deploy on staging server: deploy on staging server:
stage: deploy stage: deploy
......
...@@ -5,8 +5,8 @@ services: ...@@ -5,8 +5,8 @@ services:
image: ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} image: ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}
environment: environment:
- spring.profiles.active=dev - spring.profiles.active=dev
- JAVA_OPTIONS=-Xms1800M -Xmx2800M -server -Dnetworkaddress.cache.ttl=10 - JAVA_OPTIONS=-Xms1800M -Xmx1800M -server -Dnetworkaddress.cache.ttl=10
- base.host=${CI_COMMIT_REF_SLUG}.review.genesys-pgr.org - base.host=${CI_ENVIRONMENT_SLUG}.review.genesys-pgr.org
- robots.allow=false - robots.allow=false
- db.url=jdbc:hsqldb:mem:genesys;sql.syntax_mys=true - db.url=jdbc:hsqldb:mem:genesys;sql.syntax_mys=true
- db.driverClassName=org.hsqldb.jdbc.JDBCDriver - db.driverClassName=org.hsqldb.jdbc.JDBCDriver
...@@ -15,7 +15,7 @@ services: ...@@ -15,7 +15,7 @@ services:
- db.showSql=false - db.showSql=false
- db.hbm2ddl=true - db.hbm2ddl=true
- auto.createContent=true - auto.createContent=true
- hibernate.dialect=org.hibernate.dialect.HSQLDialect - hibernate.dialect=org.genesys.blocks.util.BetterHSQLDialect
- base.cookie-secure=true - base.cookie-secure=true
networks: networks:
- traefik-net - traefik-net
...@@ -25,10 +25,10 @@ services: ...@@ -25,10 +25,10 @@ services:
- app=genesys-review - app=genesys-review
- traefik.port=8080 - traefik.port=8080
- traefik.docker.network=traefik-net - traefik.docker.network=traefik-net
- traefik.frontend.rule=Host:${CI_COMMIT_REF_SLUG}.review.genesys-pgr.org - traefik.frontend.rule=Host:${CI_ENVIRONMENT_SLUG}.review.genesys-pgr.org
resources: resources:
limits: limits:
memory: 3g memory: 2g
cpus: '2' cpus: '2'
reservations: reservations:
memory: 2g memory: 2g
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment