Hangar/.gitlab-ci.yml

58 lines
2.3 KiB
YAML
Raw Normal View History

2020-07-29 04:07:34 +08:00
variables:
2020-08-04 04:21:34 +08:00
# Use the OverlayFS driver for improved performance.
2020-07-29 04:07:34 +08:00
DOCKER_DRIVER: overlay
2020-08-04 04:21:34 +08:00
# This will supress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
2020-08-04 04:48:44 +08:00
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
2020-08-04 04:21:34 +08:00
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
2020-08-04 04:48:44 +08:00
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
2020-08-04 04:21:34 +08:00
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
2020-07-29 04:07:34 +08:00
2020-08-04 04:21:34 +08:00
stages:
- build
- deploy
cache:
paths:
2020-08-04 04:48:44 +08:00
- .m2/repository/
2020-08-04 04:32:08 +08:00
- src/main/frontend/node
- src/main/frontend/node_modules
- target/
2020-07-29 03:00:16 +08:00
build:
2020-08-04 04:21:34 +08:00
image: maven:3-jdk-14
2020-07-29 03:00:16 +08:00
stage: build
2020-08-04 04:21:34 +08:00
script:
- 'mvn $MAVEN_CLI_OPTS package'
artifacts:
paths:
- target/hangar-*.jar
deploy:
stage: deploy
2020-08-04 04:23:31 +08:00
image: docker:latest
2020-07-29 03:00:16 +08:00
variables:
SERVICE_NAME: hangarnew
2020-08-04 04:48:44 +08:00
services:
- docker:dind
before_script:
- mkdir -pv /home/docker
- echo $DOCKER_CA_PEM >> /home/docker/ca.pem.base64
- echo $DOCKER_CERT >> /home/docker/cert.pem.base64
- echo $DOCKER_KEY >> /home/docker/key.pem.base64
- base64 -d /home/docker/ca.pem.base64 >> /home/docker/ca.pem
- base64 -d /home/docker/cert.pem.base64 >> /home/docker/cert.pem
- base64 -d /home/docker/key.pem.base64 >> /home/docker/key.pem
- alias secure-docker="docker -H tcp://glados.minidigger.me:4243 --tlsverify --tlscacert=/home/docker/ca.pem --tlscert=/home/docker/cert.pem --tlskey=/home/docker/key.pem"
2020-07-29 03:00:16 +08:00
script:
2020-07-29 04:07:34 +08:00
- apk add --no-cache docker-compose
2020-07-29 03:53:46 +08:00
- cd docker
2020-07-29 04:27:54 +08:00
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
2020-07-29 03:53:46 +08:00
- docker-compose build
- docker-compose push
- secure-docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- secure-docker stack deploy --with-registry-auth --compose-file=docker-compose.yml ${SERVICE_NAME}
2020-07-29 03:00:16 +08:00
only:
- master