Created
July 30, 2018 11:15
-
-
Save gimlet2/40db10aca23b2484bfb1991e4a55617c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: docker:latest | |
services: | |
- docker:dind | |
variables: | |
DOCKER_DRIVER: overlay | |
stages: | |
- build | |
- package | |
- deploy | |
gradle-build: | |
image: openjdk:8-jdk | |
stage: build | |
script: "./gradlew bootJar" | |
artifacts: | |
paths: | |
- build/libs/*.jar | |
docker-build: | |
stage: package | |
script: | |
- docker build -t registry.gitlab.com/<name>/<project> . | |
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com | |
- docker push registry.gitlab.com/<name>/<project> | |
deploy-prod: | |
stage: deploy | |
image: gitlab/dind:latest | |
only: | |
- "master" | |
environment: production | |
services: | |
- docker:dind | |
before_script: | |
- mkdir -p ~/.ssh | |
- echo "$DEPLOYER_KEY" | tr -d '\r' > ~/.ssh/id_rsa | |
- chmod 600 ~/.ssh/id_rsa | |
- eval "$(ssh-agent -s)" | |
- ssh-add ~/.ssh/id_rsa | |
- ssh-keyscan -H $DEPLOYER_HOST >> ~/.ssh/known_hosts | |
script: | |
- ssh $DEPLOYER_USER@$DEPLOYER_HOST "docker-compose -f /opt/api/docker-compose.yaml pull && docker-compose -f /opt/api/docker-compose.yaml up -d" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment