2021-08-05 23:36:48 -04:00
|
|
|
---
|
|
|
|
global-variables:
|
2021-12-22 16:26:23 -05:00
|
|
|
release: &release ${DRONE_TAG}
|
2021-08-05 23:36:48 -04:00
|
|
|
environment: &environment
|
|
|
|
JAVA_VERSION: 11
|
|
|
|
GRADLE_VERSION: 7.1
|
|
|
|
CRE_VERSION: dev-${DRONE_BUILD_NUMBER}
|
|
|
|
CRE_ARTIFACT_NAME: ColorRecipesExplorer
|
|
|
|
CRE_REGISTRY_IMAGE: registry.fyloz.dev:5443/colorrecipesexplorer/backend
|
|
|
|
CRE_PORT: 9101
|
2021-08-06 20:54:07 -04:00
|
|
|
CRE_RELEASE: *release
|
2021-08-05 23:36:48 -04:00
|
|
|
gradle-image: &gradle-image gradle:7.1-jdk11
|
|
|
|
alpine-image: &alpine-image alpine:latest
|
|
|
|
docker-registry-repo: &docker-registry-repo registry.fyloz.dev:5443/colorrecipesexplorer/backend
|
|
|
|
|
2021-07-31 19:13:20 -04:00
|
|
|
kind: pipeline
|
|
|
|
name: default
|
2021-08-01 00:28:40 -04:00
|
|
|
type: docker
|
|
|
|
|
2021-07-31 19:13:20 -04:00
|
|
|
steps:
|
2021-08-06 20:54:07 -04:00
|
|
|
- name: gradle-test
|
|
|
|
image: *gradle-image
|
|
|
|
commands:
|
|
|
|
- gradle test
|
|
|
|
when:
|
|
|
|
branch: develop
|
|
|
|
|
|
|
|
- name: set-docker-tags-latest
|
2021-08-05 23:36:48 -04:00
|
|
|
image: *alpine-image
|
|
|
|
environment:
|
|
|
|
<<: *environment
|
2021-08-01 17:27:16 -04:00
|
|
|
commands:
|
2021-08-06 20:54:07 -04:00
|
|
|
- echo -n "latest" > .tags
|
2021-08-04 21:34:18 -04:00
|
|
|
when:
|
|
|
|
branch: develop
|
2021-12-14 23:44:08 -05:00
|
|
|
event:
|
|
|
|
exclude:
|
|
|
|
- pull_request
|
2021-08-01 00:28:40 -04:00
|
|
|
|
2021-08-06 20:54:07 -04:00
|
|
|
- name: set-docker-tags-release
|
|
|
|
image: *alpine-image
|
|
|
|
environment:
|
|
|
|
<<: *environment
|
2021-08-01 00:28:40 -04:00
|
|
|
commands:
|
2021-08-06 20:54:07 -04:00
|
|
|
- echo -n "latest-release,$CRE_RELEASE" > .tags
|
2021-08-01 00:28:40 -04:00
|
|
|
when:
|
2021-12-22 16:26:23 -05:00
|
|
|
event:
|
|
|
|
- tag
|
2021-08-01 00:28:40 -04:00
|
|
|
|
2021-08-06 20:54:07 -04:00
|
|
|
- name: containerize-dev
|
2021-08-01 00:28:40 -04:00
|
|
|
image: plugins/docker
|
2021-08-05 23:36:48 -04:00
|
|
|
environment:
|
|
|
|
<<: *environment
|
2021-08-01 00:28:40 -04:00
|
|
|
settings:
|
2021-08-05 23:36:48 -04:00
|
|
|
build_args_from_env:
|
|
|
|
- GRADLE_VERSION
|
|
|
|
- JAVA_VERSION
|
2021-12-29 17:44:17 -05:00
|
|
|
- CRE_VERSION
|
2021-08-05 23:36:48 -04:00
|
|
|
repo: *docker-registry-repo
|
2021-08-01 00:28:40 -04:00
|
|
|
when:
|
2021-08-06 20:54:07 -04:00
|
|
|
branch: develop
|
2021-12-14 23:44:08 -05:00
|
|
|
event:
|
|
|
|
exclude:
|
|
|
|
- pull_request
|
2021-08-06 20:54:07 -04:00
|
|
|
|
|
|
|
- name: containerize-release
|
|
|
|
image: plugins/docker
|
|
|
|
environment:
|
|
|
|
<<: *environment
|
|
|
|
settings:
|
|
|
|
build_args_from_env:
|
|
|
|
- GRADLE_VERSION
|
|
|
|
- JAVA_VERSION
|
2021-12-29 17:44:17 -05:00
|
|
|
build_args:
|
|
|
|
- CRE_VERSION=${DRONE_TAG}
|
2021-08-06 20:54:07 -04:00
|
|
|
repo: *docker-registry-repo
|
|
|
|
when:
|
2021-12-22 16:26:23 -05:00
|
|
|
event:
|
|
|
|
- tag
|
2021-08-01 00:28:40 -04:00
|
|
|
|
|
|
|
- name: deploy
|
|
|
|
image: alpine:latest
|
|
|
|
environment:
|
2021-08-05 23:36:48 -04:00
|
|
|
<<: *environment
|
|
|
|
CRE_REGISTRY_IMAGE: *docker-registry-repo
|
2021-08-01 00:28:40 -04:00
|
|
|
DEPLOY_SERVER:
|
|
|
|
from_secret: deploy_server
|
|
|
|
DEPLOY_SERVER_USERNAME:
|
|
|
|
from_secret: deploy_server_username
|
|
|
|
DEPLOY_SERVER_SSH_PORT:
|
|
|
|
from_secret: deploy_server_ssh_port
|
|
|
|
DEPLOY_SERVER_SSH_KEY:
|
|
|
|
from_secret: deploy_server_ssh_key
|
2021-08-10 19:49:06 -04:00
|
|
|
DEPLOY_CONTAINER_NAME: cre_backend
|
2021-08-01 00:28:40 -04:00
|
|
|
DEPLOY_SPRING_PROFILES: mysql,rest
|
|
|
|
DEPLOY_DATA_VOLUME: /var/cre/data
|
|
|
|
DEPLOY_CONFIG_VOLUME: /var/cre/config
|
2021-12-29 17:34:14 -05:00
|
|
|
DEPLOY_LOGS_VOLUME: /var/cre/logs
|
2021-08-01 00:28:40 -04:00
|
|
|
commands:
|
|
|
|
- apk update
|
|
|
|
- apk add --no-cache openssh-client
|
|
|
|
- mkdir -p ~/.ssh
|
|
|
|
- echo "$DEPLOY_SERVER_SSH_KEY" | tr -d '\r' > ~/.ssh/id_rsa
|
|
|
|
- chmod 700 ~/.ssh/id_rsa
|
|
|
|
- eval $(ssh-agent -s)
|
|
|
|
- ssh-add ~/.ssh/id_rsa
|
|
|
|
- ssh-keyscan -p $DEPLOY_SERVER_SSH_PORT -H $DEPLOY_SERVER >> ~/.ssh/known_hosts
|
|
|
|
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
|
|
|
|
- ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker stop $DEPLOY_CONTAINER_NAME || true && docker rm $DEPLOY_CONTAINER_NAME || true"
|
2021-08-06 20:54:07 -04:00
|
|
|
- ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker pull $CRE_REGISTRY_IMAGE:$CRE_RELEASE"
|
2021-12-29 17:34:14 -05:00
|
|
|
- ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker run -d -p $CRE_PORT:9090 --name=$DEPLOY_CONTAINER_NAME -v $DEPLOY_DATA_VOLUME:/usr/bin/data -v $DEPLOY_CONFIG_VOLUME:/usr/bin/config -v $DEPLOY_LOGS_VOLUME:/usr/bin/logs -e spring_profiles_active=$DEPLOY_SPRING_PROFILES $CRE_REGISTRY_IMAGE:$CRE_RELEASE"
|
2021-08-01 00:28:40 -04:00
|
|
|
when:
|
2021-12-22 16:26:23 -05:00
|
|
|
event:
|
2021-12-23 21:01:31 -05:00
|
|
|
- tag
|