ci: jsonnet-drone@0.1.0
continuous-integration/drone/push Build is passing Details
continuous-integration/drone Build is passing Details

This commit is contained in:
Giles Bradshaw 2020-08-28 21:54:34 +01:00
parent b49ae2ed69
commit 21255d709a
25 changed files with 338 additions and 43 deletions

View File

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

View File

@ -1,14 +0,0 @@
load("@this//guacamole:drone.star", "drone")
load("@this//guacamole:stack-name.star", "stackName")
load("@this//guacamole: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 @@
docker build guacamole-postgresql -t ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/guacamole-postgresql

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(
'guacamole',
'/stack/',
[],
publicSecrets,
secretSecrets,
[
'REGISTRY_DOMAIN',
'REGISTRY_PORT',
'REGISTRY_PASSWORD',
],
) {
trigger +: {
event +: [
'promote',
],
target +: [
'production',
],
},
},
]

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

@ -0,0 +1,151 @@
---
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
- postgres_db
- postgres_user
- postgres_password
host: ${SSH_HOST}
key: ${SSH_KEY}
passphrase: ${SSH_PASSPHRASE}
port: ${SSH_PORT}
script:
- rm -f env-guacamole
- "echo \"export POSTGRES_DB='$${POSTGRES_DB}'\" >> env-guacamole # \"postgres-db\""
- "echo \"export POSTGRES_USER='$${POSTGRES_USER}'\" >> env-guacamole # \"postgres-user\""
- "echo \"export POSTGRES_PASSWORD='$${POSTGRES_PASSWORD}'\" >> env-guacamole # \"postgres-password\""
username: ${SSH_USER}
environment:
POSTGRES_DB:
from_secret: postgres-db
POSTGRES_PASSWORD:
from_secret: postgres-password
POSTGRES_USER:
from_secret: postgres-user
- 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/guacamole
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
- postgres_db
- postgres_user
- postgres_password
host: ${SSH_HOST}
key: ${SSH_KEY}
passphrase: ${SSH_PASSPHRASE}
port: ${SSH_PORT}
script:
- export POSTGRES_PASSWORD=$${POSTGRES_PASSWORD}
- export POSTGRES_DB=$${POSTGRES_DB}
- export POSTGRES_USER=$${POSTGRES_USER}
- export REGISTRY_DOMAIN=$${REGISTRY_DOMAIN}
- export REGISTRY_PORT=$${REGISTRY_PORT}
- export REGISTRY_PASSWORD=$${REGISTRY_PASSWORD}
- set -e
- cd /stack/guacamole
- sh .drone/login.sh
- sh .drone/pull.sh
- sh .drone/deploy.sh
username: ${SSH_USER}
environment:
POSTGRES_DB:
from_secret: postgres-db
POSTGRES_PASSWORD:
from_secret: postgres-password
POSTGRES_USER:
from_secret: postgres-user
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,4 @@
[
'postgres-db',
'postgres-user',
]

View File

@ -0,0 +1,3 @@
[
'postgres-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 @@
docker pull ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/guacamole-postgresql

1
.drone/push.sh Normal file
View File

@ -0,0 +1 @@
docker push ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/guacamole-postgresql

55
.drone/yarn-error.log Normal file
View File

@ -0,0 +1,55 @@
Arguments:
/usr/local/Cellar/node/11.9.0/bin/node /usr/local/Cellar/yarn/1.13.0/libexec/bin/yarn.js
PATH:
/Users/giles/.cargo/bin:/Users/giles/.local/bin:/Users/giles/Library/Python/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/usr/local/share/dotnet/sdk:/usr/local/share/dotnet/sdk/2.2.101:/opt/X11/bin:~/.dotnet/tools:/usr/local/bin:/usr/local/Cellar/openssl/1.0.2j/bin/openssl
Yarn version:
1.13.0
Node version:
12.13.1
Platform:
darwin x64
Trace:
Error: getaddrinfo ENOTFOUND registry.yarnpkg.com
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)
npm manifest:
{
"private": true,
"scripts": {
"build": "drone jsonnet --source drone-home.jsonnet --target drone-home.yml --stream"
},
"dependencies": {
"@sigyl/jsonnet-drone": "^0.0.3"
}
}
yarn manifest:
No manifest
Lockfile:
# 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.0.2":
version "0.0.2"
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone/-/jsonnet-drone-0.0.2.tgz#64572524155eaa2c2b8bda6102f238a0269cafbb"
integrity sha512-1/EZR5Vbo8oKAm+R31XIzsS6VZxcEIcRLyrLi53JQ0+z+CWLPvrUwiq0homBysYJhqk1XRzYF6+ctwbbmmzxrA==
dependencies:
"@sigyl/jsonnet-compose" "^0.0.2"
"@sigyl/jsonnet-drone-environment" "0.0.5"

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
View File

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

View File

@ -2,6 +2,13 @@
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.4](https://sigyl.com///compare/v0.0.3...v0.0.4) "chore(release): 0.0.4" (2020-08-19)
### Bug Fixes
* build and deloy scripts ([b6f60a1](https://sigyl.com///commit/b6f60a17bf23165b355085b63f879b1949f34888))
### [0.0.3](https://sigyl.com///compare/v0.0.1...v0.0.3) "chore(release): 0.0.3" (2020-08-11)
### [0.0.2](https://sigyl.com///compare/v0.0.1...v0.0.2) (2020-08-11)

View File

@ -2,9 +2,9 @@
## secrets
* guacamole-postgres-password
* local-docker-registry
* registry-password
* postgres-password
* postgres-user
* postgres-db
## initial deployment

View File

@ -1 +0,0 @@
docker build guacamole-postgresql -t ${LOCAL_DOCKER_REGISTRY}guacamole-postgresql

View File

@ -8,9 +8,9 @@ services:
replicas: 1
restart_policy:
condition: any
image: ${LOCAL_DOCKER_REGISTRY}guacamole-postgresql:latest
image: ${REGISTRY_DOMAIN}:${REGISTRY_PORT}/guacamole-postgresql:latest
environment:
POSTGRES_PASSWORD: ${GUACAMOLE_POSTGRES_PASSWORD}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: guacamole_db
volumes:
- guacamole-postgresql-data:/var/lib/postgresql/data
@ -35,12 +35,12 @@ services:
replicas: 1
restart_policy:
condition: any
image: guacamole/guacamole:latest
image: guacamole/guacamole:1.2.0@sha256:6eb0b854e8e145df8f9220b92e51d52e9ff18c4262de20d56ccc62a4dad835b9
environment:
- POSTGRES_HOSTNAME=guacamole-postgresql
- POSTGRES_PORT=5432
- POSTGRES_USER=guacamole_user
- POSTGRES_PASSWORD=${GUACAMOLE_POSTGRES_PASSWORD}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DATABASE=guacamole_db
- GUACD_HOSTNAME=guacd
networks:

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"

View File

@ -1,2 +1,2 @@
FROM postgres:12
FROM postgres:12.4@sha256:b0cfe264cb1143c7c660ddfd5c482464997d62d6bc9f97f8fdf3deefce881a8c
COPY *.sql /

View File

@ -1,2 +1,2 @@
docker exec -it $1 psql -U postgres -d $GUACAMOLE_POSTGRES_DB -f /initdb.sql
docker exec -it $1 psql -U postgres -d $GUACAMOLE_POSTGRES_DB -f /init-user.sql -v password=$GUACAMOLE_POSTGRES_PASSWORD -v user=$GUACAMOLE_POSTGRES_USER
docker exec -it $1 psql -U postgres -d $GUACAMOLE_POSTGRES_DB -f /init-user.sql -v password=$POSTGRES_PASSWORD -v user=$POSTGRES_USER

View File

@ -1,11 +1,9 @@
{
"private": true,
"name": "guacamole",
"version": "0.0.3",
"version": "0.0.4",
"description": "remote access",
"scripts": {
"build": "sh build.sh",
"deploy": "sh deploy.sh",
"release": "standard-version",
"test": "echo \"Error: no test specified\" && exit 1"
},

View File

@ -23,6 +23,18 @@
chalk "^2.0.0"
js-tokens "^4.0.0"
"@babel/runtime@^7.4.5":
version "7.11.2"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.11.2.tgz#f549c13c754cc40b87644b9fa9f09a6a95fe0736"
integrity sha512-TeWkU52so0mPtDcaCTxNBI/IHiz0pZgr8VEFqXFtZWpYD08ZB6FaSwVAS8MKRQAP3bYKiVjwysOJgMFY28o6Tw==
dependencies:
regenerator-runtime "^0.13.4"
"@rbicker/jsonnet@0.1.1-0.12.1":
version "0.1.1-0.12.1"
resolved "https://registry.yarnpkg.com/@rbicker/jsonnet/-/jsonnet-0.1.1-0.12.1.tgz#4d7bf08bed25537b81f3a83aaa22300962ed0f8c"
integrity sha512-G5/t8pf/xqTSDPgRKYoomwR8ql2iZ2G0hzrqv4BxWIizyjiKTPU6V3H/iL7XzOWXbJNEjHHiYdGx3aOOJ2pPfg==
"@types/color-name@^1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
@ -187,6 +199,11 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
commander@2.20.0:
version "2.20.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422"
integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==
compare-func@^1.3.1:
version "1.3.4"
resolved "https://registry.yarnpkg.com/compare-func/-/compare-func-1.3.4.tgz#6b07c4c5e8341119baf44578085bda0f4a823516"
@ -729,6 +746,15 @@ json-stringify-safe@^5.0.1:
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=
jsonnet-cli@^0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/jsonnet-cli/-/jsonnet-cli-0.0.3.tgz#d6248c9a8c7fbbb4f02c3ff4300577b99d50a0e1"
integrity sha512-ylICpZamAxVum0Zxt3aoDm4C2qUPFM03Ii9EIl/joZjr6gHdPyxzg245PSRvYbyBsi3YqLAtsrx/3etYWTn+4g==
dependencies:
"@rbicker/jsonnet" "0.1.1-0.12.1"
commander "2.20.0"
yaml "1.6.0"
jsonparse@^1.2.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
@ -1231,6 +1257,11 @@ redent@^3.0.0:
indent-string "^4.0.0"
strip-indent "^3.0.0"
regenerator-runtime@^0.13.4:
version "0.13.7"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==
repeating@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda"
@ -1555,6 +1586,13 @@ y18n@^4.0.0:
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
yaml@1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.6.0.tgz#d8a985cfb26086dd73f91c637f6e6bc909fddd3c"
integrity sha512-iZfse3lwrJRoSlfs/9KQ9iIXxs9++RvBFVzAqbbBiFT+giYtyanevreF9r61ZTbGMgWQBxAua3FzJiniiJXWWw==
dependencies:
"@babel/runtime" "^7.4.5"
yargs-parser@^18.1.2, yargs-parser@^18.1.3:
version "18.1.3"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"