ci: jsonnet-drone@0.1.0

This commit is contained in:
Giles Bradshaw 2020-08-28 22:17:12 +01:00
parent e0ca87f07d
commit 01baef6591
20 changed files with 1836 additions and 21 deletions

View File

@ -1,14 +0,0 @@
load("@this//zabbix:drone.star", "drone")
load("@this//zabbix:stack-name.star", "stackName")
load("@this//zabbix:stack-root.star", "stackRoot")
def main(ctx):
return drone(
ctx,
"home-deploy",
stackRoot,
stackName,
[]
)

1
.drone/build.sh Normal file
View File

@ -0,0 +1 @@
echo 'nothing to build'

4
.drone/deploy.sh Normal file
View File

@ -0,0 +1,4 @@
docker stack rm zabbix
echo 'sleeping...60'
sleep 60
docker stack deploy -c docker-compose.yml zabbix

30
.drone/drone-home.jsonnet Normal file
View File

@ -0,0 +1,30 @@
local secretSecrets = import 'lib/secret-secrets.libsonnet';
local publicSecrets = import 'lib/public-secrets.libsonnet';
local deploy = import 'node_modules/@sigyl/jsonnet-drone/deploy.libsonnet';
local register = import 'node_modules/@sigyl/jsonnet-drone/register.libsonnet';
[
register,
deploy(
'zabbix',
'/stack/',
[],
publicSecrets,
secretSecrets,
[
'REGISTRY_DOMAIN',
'REGISTRY_PORT',
'REGISTRY_PASSWORD',
],
) {
trigger +: {
event +: [
'promote',
],
target +: [
'production',
],
},
},
]

143
.drone/drone-home.yml Normal file
View File

@ -0,0 +1,143 @@
---
kind: pipeline
type: docker
name: register
platform:
os: linux
arch: amd64
clone:
disable: true
trigger:
event:
exclude:
- promote
---
kind: pipeline
type: docker
name: deploy
platform:
os: linux
arch: amd64
steps:
- name: print env
image: appleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- mysql_password
- mysql_root_password
host: ${SSH_HOST}
key: ${SSH_KEY}
passphrase: ${SSH_PASSPHRASE}
port: ${SSH_PORT}
script:
- rm -f env-zabbix
- "echo \"export MYSQL_PASSWORD='$${MYSQL_PASSWORD}'\" >> env-zabbix # \"mysql-password\""
- "echo \"export MYSQL_ROOT_PASSWORD='$${MYSQL_ROOT_PASSWORD}'\" >> env-zabbix # \"mysql-root-password\""
username: ${SSH_USER}
environment:
MYSQL_PASSWORD:
from_secret: mysql-password
MYSQL_ROOT_PASSWORD:
from_secret: mysql-root-password
- name: scp
image: appleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47
settings:
command_timeout: 2m
host: ${SSH_HOST}
key: ${SSH_KEY}
passphrase: ${SSH_PASSPHRASE}
port: ${SSH_PORT}
source:
- .
target: /stack/zabbix
username: ${SSH_USER}
- name: wait
image: alpine:3.12.0@sha256:90baa0922fe90624b05cb5766fa5da4e337921656c2f8e2b13bd3c052a0baac1
commands:
- sleep 15
- name: "dockerbuild:"
image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f
commands:
- set -e
- sh .drone/login.sh
- sh .drone/build.sh
- sh .drone/push.sh
- sh .drone/logout.sh
volumes:
- name: dockersock
path: /var/run
- name: deploy
image: appleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- registry_domain
- registry_port
- registry_password
- mysql_password
- mysql_root_password
host: ${SSH_HOST}
key: ${SSH_KEY}
passphrase: ${SSH_PASSPHRASE}
port: ${SSH_PORT}
script:
- export MYSQL_PASSWORD=$${MYSQL_PASSWORD}
- export MYSQL_ROOT_PASSWORD=$${MYSQL_ROOT_PASSWORD}
- export REGISTRY_DOMAIN=$${REGISTRY_DOMAIN}
- export REGISTRY_PORT=$${REGISTRY_PORT}
- export REGISTRY_PASSWORD=$${REGISTRY_PASSWORD}
- set -e
- cd /stack/zabbix
- sh .drone/login.sh
- sh .drone/pull.sh
- sh .drone/deploy.sh
username: ${SSH_USER}
environment:
MYSQL_PASSWORD:
from_secret: mysql-password
MYSQL_ROOT_PASSWORD:
from_secret: mysql-root-password
services:
- name: docker
image: docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f
privileged: true
volumes:
- name: dockersock
path: /var/run
- name: ca
path: /etc/docker/certs.d
volumes:
- name: dockersock
temp: {}
- name: ca
host:
path: /etc/docker/certs.d
trigger:
event:
- promote
target:
- production
...

View File

@ -0,0 +1 @@
[]

View File

@ -0,0 +1,4 @@
[
"mysql-password",
"mysql-root-password",
]

1
.drone/login.sh Normal file
View File

@ -0,0 +1 @@
docker login ${REGISTRY_DOMAIN}:${REGISTRY_PORT} --username client --password "${REGISTRY_PASSWORD}"

1
.drone/logout.sh Normal file
View File

@ -0,0 +1 @@
docker logout ${REGISTRY_DOMAIN}:${REGISTRY_PORT}

9
.drone/package.json Normal file
View File

@ -0,0 +1,9 @@
{
"private": true,
"scripts": {
"build": "drone jsonnet --source drone-home.jsonnet --target drone-home.yml --stream"
},
"dependencies": {
"@sigyl/jsonnet-drone": "^0.1.0"
}
}

1
.drone/pull.sh Normal file
View File

@ -0,0 +1 @@
echo 'nothing to pull'

1
.drone/push.sh Normal file
View File

@ -0,0 +1 @@
echo 'nothing to push'

21
.drone/yarn.lock Normal file
View File

@ -0,0 +1,21 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@sigyl/jsonnet-compose@^0.0.2":
version "0.0.2"
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-compose/-/jsonnet-compose-0.0.2.tgz#8900a21e8cd8109929b6042703f8645aacb9bcda"
integrity sha512-wWS3CgPeNi/o1pcS6n/4pafxlMD0KC9/RKMZr/ySmzeGNRW++sPuKuxajYse2TNd47uNDdeUSnk4aEeEIKL0zA==
"@sigyl/jsonnet-drone-environment@0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone-environment/-/jsonnet-drone-environment-0.0.5.tgz#9ea85e08904777bd21a3e4b30b0b91461d0285ff"
integrity sha512-xVGmdMO1pOyozAWUbJm6mzKBgsLPJ+1hWnGCK3AxPkr7kkDh18hu30+TLzlcQtqq76s5jUfvJUztezsGj/mIcw==
"@sigyl/jsonnet-drone@^0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone/-/jsonnet-drone-0.1.0.tgz#feda1797e8e9ef799cad72e65f7163ca26a9e3a5"
integrity sha512-QY/ngucxFOtLfL8Mt0f2bxN4fQDUOGOFtaRpSH2cNyg84xADkzehT0ORZtbLitr+AwhyF5KN/zAGvzkyNAoqPw==
dependencies:
"@sigyl/jsonnet-compose" "^0.0.2"
"@sigyl/jsonnet-drone-environment" "0.0.5"

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules
.log

3
.versionrc Normal file
View File

@ -0,0 +1,3 @@
{
"tagMessageInChangeLog": true
}

5
CHANGELOG.md Normal file
View File

@ -0,0 +1,5 @@
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### 0.0.2 "chore(release): 0.0.2" (2020-08-19)

View File

@ -7,17 +7,17 @@ services:
replicas: 1
restart_policy:
condition: any
image: mariadb:10
image: mariadb:10.5.5@sha256:589c4347e21c2dd4292d8929091faf6d78e80acdcca6cb04aa0a1337f22765f1
command: --max-allowed-packet=128MB
networks:
- appnet
volumes:
- zabbix-mariadb:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: ${ZABBIX_MYSQL_ROOT_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_USER: zabbix
MYSQL_DATABASE: zabbix
MYSQL_PASSWORD: ${ZABBIX_MYSQL_PASSWORD}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
zabbix-server:
deploy:
placement:
@ -25,13 +25,13 @@ services:
replicas: 1
restart_policy:
condition: any
image: zabbix/zabbix-server-mysql
image: zabbix/zabbix-server-mysql:alpine-5.0.3@sha256:756ca5415e46be573c76d73bd1a26c96f99bc42641773236e31e718ae9151b29
networks:
- appnet
environment:
DB_SERVER_HOST: zabbix-mariadb
MYSQL_USER: zabbix
MYSQL_PASSWORD: ${ZABBIX_MYSQL_PASSWORD}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
networks:
- appnet
ports:
@ -44,14 +44,14 @@ services:
replicas: 1
restart_policy:
condition: any
image: zabbix/zabbix-web-nginx-mysql
image: zabbix/zabbix-web-nginx-mysql:alpine-5.0.3@sha256:ae124bb49627da3f687c7345241bba8b771dcb10406360b20771f3732b94177c
networks:
- appnet
- externalnet
environment:
DB_SERVER_HOST: zabbix-mariadb
MYSQL_USER: zabbix
MYSQL_PASSWORD: ${ZABBIX_MYSQL_PASSWORD}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ZBX_SERVER_HOST: zabbix-server
PHP_TZ: Europe/London
volumes:

3
git-hooks/pre-commit Executable file
View File

@ -0,0 +1,3 @@
drone jsonnet --source .drone/drone-home.jsonnet --target .drone/drone-home.yml --stream \
&& git add .drone/drone-home.yml \
&& echo "jsonnet built"

18
package.json Normal file
View File

@ -0,0 +1,18 @@
{
"private": true,
"name": "zabbix",
"version": "0.0.2",
"scripts": {
"release": "standard-version",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://sigyl.com/git/stack/zabbix"
},
"author": "Giles Bradshaw",
"license": "ISC",
"devDependencies": {
"standard-version": "git+https://github.com/gilesbradshaw/standard-version.git"
}
}

1581
yarn.lock Normal file

File diff suppressed because it is too large Load Diff