84 lines
2.6 KiB
YAML
84 lines
2.6 KiB
YAML
kind: pipeline
|
|
name: default
|
|
type: docker
|
|
|
|
environment:
|
|
CRE_VERSION: ${DRONE_BUILD_NUMBER}
|
|
CRE_ARTIFACT_NAME: ColorRecipesExplorer-backend-${DRONE_BUILD_NUMBER}
|
|
CRE_REGISTRY_IMAGE: registry.fyloz.dev:5443/colorrecipesexplorer/backend
|
|
CRE_PORT: 9090
|
|
|
|
steps:
|
|
- name: bla
|
|
image: alpine:latest
|
|
commands:
|
|
- echo $${CRE_ARTIFACT_NAME}
|
|
- echo $CRE_ARTIFACT_NAME
|
|
- echo ${DRONE_BRANCH}
|
|
|
|
- name: test
|
|
image: gradle:7.1-jdk11
|
|
commands:
|
|
- gradle test
|
|
when:
|
|
branch:
|
|
- master
|
|
|
|
- name: build
|
|
image: gradle:7.1-jdk11
|
|
commands:
|
|
- gradle bootJar -Pversion=$CRE_VERSION
|
|
- mv build/libs/ColorRecipesExplorer-$CRE_VERSION.jar $CRE_ARTIFACT_NAME
|
|
when:
|
|
branch:
|
|
- master
|
|
|
|
- name: containerize
|
|
image: plugins/docker
|
|
settings:
|
|
build_args:
|
|
- JDK_VERSION=11
|
|
- PORT=${CRE_PORT}
|
|
- ARTIFACT_NAME=${CRE_ARTIFACT_NAME}
|
|
repo: ${CRE_REGISTRY_IMAGE}
|
|
tags:
|
|
- latest
|
|
- ${CRE_VERSION}
|
|
when:
|
|
branch:
|
|
- master
|
|
|
|
- name: deploy
|
|
image: alpine:latest
|
|
environment:
|
|
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
|
|
DEPLOY_CONTAINER_NAME: cre_backend-${DRONE_BRANCH}
|
|
DEPLOY_SPRING_PROFILES: mysql,rest
|
|
DEPLOY_DATA_VOLUME: /var/cre/data
|
|
DEPLOY_CONFIG_VOLUME: /var/cre/config
|
|
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"
|
|
- ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker pull $CRE_REGISTRY_IMAGE:latest"
|
|
- ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker run -d -p $CRE_PORT:$CRE_PORT --name=$DEPLOY_CONTAINER_NAME -v $DEPLOY_DATA_VOLUME:/usr/bin/cre/data -v $DEPLOY_CONFIG_VOLUME:/usr/bin/cre/config -e spring_profiles_active=$SPRING_PROFILES $CRE_REGISTRY_IMAGE"
|
|
when:
|
|
branch:
|
|
- master
|
|
|
|
|