--- global-variables: release: &release ${DRONE_TAG} environment: &environment DOCS_VERSION: dev-${DRONE_BUILD_NUMBER} DOCS_REGISTRY_IMAGE: registry.fyloz.dev/colorrecipesexplorer/docs DOCS_PORT: 9103 DOCS_RELEASE: *release alpine-image: &alpine-image alpine:latest docker-registry: &docker-registry registry.fyloz.dev docker-registry-repo: &docker-registry-repo registry.fyloz.dev/colorrecipesexplorer/docs kind: pipeline name: default type: docker steps: - name: set-docker-tags-latest image: *alpine-image environment: <<: *environment commands: - echo -n "latest" > .tags when: branch: develop event: exclude: - pull_request - name: set-docker-tags-release image: *alpine-image environment: <<: *environment commands: - echo -n "latest-release,$DOCS_RELEASE" > .tags when: event: - tag - name: containerize-release image: plugins/docker environment: <<: *environment settings: registry: *docker-registry repo: *docker-registry-repo username: from_secret: docker_username password: from_secret: docker_password when: event: - tag - name: deploy image: alpine:latest environment: <<: *environment DOCS_REGISTRY_IMAGE: *docker-registry-repo 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_docs 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 $DOCS_REGISTRY_IMAGE:$DOCS_RELEASE" - ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker run -d -p $DOCS_PORT:80 --name=$DEPLOY_CONTAINER_NAME $DOCS_REGISTRY_IMAGE:$DOCS_RELEASE" when: event: - tag