From db9de5342f171c4f78e470c58c028501d5c23830 Mon Sep 17 00:00:00 2001 From: lars Date: Mon, 2 Oct 2023 11:51:20 -0500 Subject: [PATCH] Deply on commit --- .drone.yml | 16 ++++++++++++++++ .env | 2 ++ docker-compose.yml | 20 ++++++++++++++++++++ portainer_deploy.compose.yml | 11 +++++++++++ portainer_deploy.json | 25 +++++++++++++++++++++++++ portainer_deploy.template.json | 25 +++++++++++++++++++++++++ 6 files changed, 99 insertions(+) create mode 100644 .drone.yml create mode 100644 .env create mode 100644 docker-compose.yml create mode 100644 portainer_deploy.compose.yml create mode 100644 portainer_deploy.json create mode 100644 portainer_deploy.template.json diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..171877d --- /dev/null +++ b/.drone.yml @@ -0,0 +1,16 @@ +kind: pipeline +type: docker +name: deploy + +steps: + - name: Push to Portainer + image: alpine + commands: + - apk update + - apk add envsubst curl + - envsubst < portainer_deploy.template.json > portainer_deploy.json + - curl -d "portainer_deploy.json" -H "X-Api-Key=ptr_RwxH2Cd+htdD2FoFiG46erT9beyvj9VoF3BrQPtDH3Q=" -X POST https://dvportainer.privatedns.org/stacks/create/standalone/repository + +trigger: + branch: + - main \ No newline at end of file diff --git a/.env b/.env new file mode 100644 index 0000000..f319a87 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +HOST=dvdemo.localhost +ECHO_PATH=echo \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..741eeee --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3.4' + +services: + http-echo: + container_name: http-echo + image: mendhak/http-https-echo:latest + expose: + - 8080 + environment: + - VIRTUAL_PORT=8080 + - VIRTUAL_HOST=${HOST} + - VIRTUAL_PATH=/${ECHO_PATH}/ + - VIRTUAL_DEST=/ + networks: + - cicd + +networks: + cicd: + driver: bridge + external: true \ No newline at end of file diff --git a/portainer_deploy.compose.yml b/portainer_deploy.compose.yml new file mode 100644 index 0000000..5210db5 --- /dev/null +++ b/portainer_deploy.compose.yml @@ -0,0 +1,11 @@ +version: '3.4' + +services: + http-echo: + networks: + - cicd + +networks: + cicd: + driver: bridge + external: true \ No newline at end of file diff --git a/portainer_deploy.json b/portainer_deploy.json new file mode 100644 index 0000000..ff2c867 --- /dev/null +++ b/portainer_deploy.json @@ -0,0 +1,25 @@ +{ + "additionalFiles": [], + "autoUpdate": { + "forcePullImage": false, + "forceUpdate": false, + "interval": "1m30s", + "jobID": "15", + "webhook": "05de31a2-79fa-4644-9c12-faa67e5c49f0" + }, + "composeFile": "docker-compose.yml", + "env": [ + { + "HOST": "dvdemo.privatedns.org", + "ECHO_PATH": "deployed_echo" + } + ], + "fromAppTemplate": false, + "name": "DeployTest_test1", + "repositoryAuthentication": true, + "repositoryUsername": "cicd", + "repositoryPassword": "gJ6@$7ZjWGyV4%i", + "repositoryReferenceName": "/refs/heads/main", + "repositoryURL": "https://dvgit.privatedns.org/lars/DeployTests", + "tlsskipVerify": false +} diff --git a/portainer_deploy.template.json b/portainer_deploy.template.json new file mode 100644 index 0000000..c12df2f --- /dev/null +++ b/portainer_deploy.template.json @@ -0,0 +1,25 @@ +{ + "additionalFiles": [], + "autoUpdate": { + "forcePullImage": false, + "forceUpdate": false, + "interval": "1m30s", + "jobID": "15", + "webhook": "05de31a2-79fa-4644-9c12-faa67e5c49f0" + }, + "composeFile": "docker-compose.yml", + "env": [ + { + "HOST": "dvdemo.privatedns.org", + "ECHO_PATH": "deployed_echo" + } + ], + "fromAppTemplate": false, + "name": "DeployTest_${DRONE_COMMIT}", + "repositoryAuthentication": true, + "repositoryUsername": "cicd", + "repositoryPassword": "gJ6@$7ZjWGyV4%i", + "repositoryReferenceName": "${DRONE_COMMIT_REF}", + "repositoryURL": "${DRONE_REPO_LINK}", + "tlsskipVerify": false +} \ No newline at end of file