fix: chnaged to jsonnet for build

This commit is contained in:
Giles Bradshaw 2020-08-27 00:14:17 +01:00
parent e0aa94da46
commit af8d7a3caa
16 changed files with 259 additions and 3 deletions

1
.drone/build.sh Normal file
View File

@ -0,0 +1 @@
docker build drone-starlark -t ${LOCAL_DOCKER_REGISTRY}drone-starlark

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

@ -0,0 +1,17 @@
local secretSecrets = import 'lib/secret-secrets.libsonnet';
local publicSecrets = import 'lib/public-secrets.libsonnet';
local deploy = import 'node_modules/@sigyl/jsonnet-drone/deploy.libsonnet';
[
deploy(
'drone',
'/stack/',
[
'LOCAL_DOCKER_REGISTRY',
'REGISTRY_PASSWORD',
],
publicSecrets,
secretSecrets
),
]

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

@ -0,0 +1,184 @@
---
kind: pipeline
type: docker
name: deploy
platform:
os: linux
arch: amd64
steps:
- name: print env
image: appleboy/drone-ssh:1.6.2
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- local_docker_registry
- registry_password
- drone_domain
- drone_gitea_client_id
- drone_gitea_server
- drone_server_host
- drone_convert_secret
- drone_gitea_client_secret
- drone_rpc_secret
host:
from_secret: ssh-host
key:
from_secret: ssh-key
port:
from_secret: ssh-port
script:
- rm -f env-drone
- "echo \"export LOCAL_DOCKER_REGISTRY='$${LOCAL_DOCKER_REGISTRY}'\" >> env-drone # \"local-docker-registry\""
- "echo \"export REGISTRY_PASSWORD='$${REGISTRY_PASSWORD}'\" >> env-drone # \"registry-password\""
- "echo \"export DRONE_DOMAIN='$${DRONE_DOMAIN}'\" >> env-drone # \"drone-domain\""
- "echo \"export DRONE_GITEA_CLIENT_ID='$${DRONE_GITEA_CLIENT_ID}'\" >> env-drone # \"drone-gitea-client-id\""
- "echo \"export DRONE_GITEA_SERVER='$${DRONE_GITEA_SERVER}'\" >> env-drone # \"drone-gitea-server\""
- "echo \"export DRONE_SERVER_HOST='$${DRONE_SERVER_HOST}'\" >> env-drone # \"drone-server-host\""
- "echo \"export DRONE_CONVERT_SECRET='$${DRONE_CONVERT_SECRET}'\" >> env-drone # \"drone-convert-secret\""
- "echo \"export DRONE_GITEA_CLIENT_SECRET='$${DRONE_GITEA_CLIENT_SECRET}'\" >> env-drone # \"drone-gitea-client-secret\""
- "echo \"export DRONE_RPC_SECRET='$${DRONE_RPC_SECRET}'\" >> env-drone # \"drone-rpc-secret\""
username:
from_secret: ssh-user
environment:
DRONE_CONVERT_SECRET:
from_secret: drone-convert-secret
DRONE_DOMAIN:
from_secret: drone-domain
DRONE_GITEA_CLIENT_ID:
from_secret: drone-gitea-client-id
DRONE_GITEA_CLIENT_SECRET:
from_secret: drone-gitea-client-secret
DRONE_GITEA_SERVER:
from_secret: drone-gitea-server
DRONE_RPC_SECRET:
from_secret: drone-rpc-secret
DRONE_SERVER_HOST:
from_secret: drone-server-host
LOCAL_DOCKER_REGISTRY:
from_secret: local-docker-registry
REGISTRY_PASSWORD:
from_secret: registry-password
- name: scp
image: appleboy/drone-scp:1.6.2
settings:
command_timeout: 2m
host:
from_secret: ssh-host
key:
from_secret: ssh-key
port:
from_secret: ssh-port
source:
- .
target: /stack/drone
username:
from_secret: ssh-user
- name: wait
image: alpine
commands:
- sleep 15
- name: "dockerbuild:"
image: docker:dind
commands:
- set -e
- sh .drone/login.sh
- sh .drone/build.sh
- sh .drone/push.sh
- sh .drone/logout.sh
environment:
LOCAL_DOCKER_REGISTRY:
from_secret: local-docker-registry
REGISTRY_PASSWORD:
from_secret: registry-password
volumes:
- name: dockersock
path: /var/run
- name: deploy
image: appleboy/drone-ssh:1.6.2
settings:
envs:
- drone_tag
- drone_commit
- drone_build_number
- drone_repo_name
- drone_repo_namespace
- drone_domain
- drone_gitea_client_id
- drone_gitea_server
- drone_server_host
- drone_convert_secret
- drone_gitea_client_secret
- drone_rpc_secret
- local_docker_registry
- registry_password
host:
from_secret: ssh-host
key:
from_secret: ssh-key
port:
from_secret: ssh-port
script:
- export DRONE_CONVERT_SECRET=$${DRONE_CONVERT_SECRET}
- export DRONE_GITEA_CLIENT_SECRET=$${DRONE_GITEA_CLIENT_SECRET}
- export DRONE_RPC_SECRET=$${DRONE_RPC_SECRET}
- export DRONE_DOMAIN=$${DRONE_DOMAIN}
- export DRONE_GITEA_CLIENT_ID=$${DRONE_GITEA_CLIENT_ID}
- export DRONE_GITEA_SERVER=$${DRONE_GITEA_SERVER}
- export DRONE_SERVER_HOST=$${DRONE_SERVER_HOST}
- export LOCAL_DOCKER_REGISTRY=$${LOCAL_DOCKER_REGISTRY}
- export REGISTRY_PASSWORD=$${REGISTRY_PASSWORD}
- set -e
- cd /stack/drone
- sh .drone/login.sh
- sh .drone/pull.sh
- sh .drone/deploy.sh
username:
from_secret: ssh-user
environment:
DRONE_CONVERT_SECRET:
from_secret: drone-convert-secret
DRONE_DOMAIN:
from_secret: drone-domain
DRONE_GITEA_CLIENT_ID:
from_secret: drone-gitea-client-id
DRONE_GITEA_CLIENT_SECRET:
from_secret: drone-gitea-client-secret
DRONE_GITEA_SERVER:
from_secret: drone-gitea-server
DRONE_RPC_SECRET:
from_secret: drone-rpc-secret
DRONE_SERVER_HOST:
from_secret: drone-server-host
LOCAL_DOCKER_REGISTRY:
from_secret: local-docker-registry
REGISTRY_PASSWORD:
from_secret: registry-password
services:
- name: docker
image: docker:dind
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
...

View File

@ -0,0 +1,6 @@
[
'drone-domain',
'drone-gitea-client-id',
'drone-gitea-server',
'drone-server-host',
]

View File

@ -0,0 +1,5 @@
[
'drone-convert-secret',
'drone-gitea-client-secret',
'drone-rpc-secret',
]

1
.drone/login.sh Normal file
View File

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

1
.drone/logout.sh Normal file
View File

@ -0,0 +1 @@
docker logout ${LOCAL_DOCKER_REGISTRY}

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.0.7"
}
}

1
.drone/pull.sh Normal file
View File

@ -0,0 +1 @@
docker build drone-starlark -t ${LOCAL_DOCKER_REGISTRY}drone-starlark

1
.drone/push.sh Normal file
View File

@ -0,0 +1 @@
docker push ${LOCAL_DOCKER_REGISTRY}drone-starlark

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.0.7":
version "0.0.7"
resolved "https://registry.yarnpkg.com/@sigyl/jsonnet-drone/-/jsonnet-drone-0.0.7.tgz#0f92ef15096b0c5497741ff56bfbd249de9edd66"
integrity sha512-353n/zExNnKPPZ235eLX3/DFXJVNIX8fdAeG3RvY+55538eGzDIk0/3HJd8jXsD6y0zxm+LexW5HghvXBMBOEA==
dependencies:
"@sigyl/jsonnet-compose" "^0.0.2"
"@sigyl/jsonnet-drone-environment" "0.0.5"

View File

@ -2,4 +2,10 @@
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)
### [0.0.3](https://sigyl.com///compare/v0.0.2...v0.0.3) "chore(release): 0.0.3" (2020-08-19)
### [0.0.2](https://sigyl.com///compare/v0.0.1...v0.0.2) "chore(release): 0.0.2" (2020-08-19)
### 0.0.1 "chore(release): 0.0.1" (2020-08-11)

View File

@ -8,7 +8,7 @@ services:
replicas: 1
restart_policy:
condition: any
image: drone/drone:1.7.0
image: drone/drone:1.9.0
volumes:
- drone:/var/lib/drone
- drone-data:/data
@ -39,7 +39,7 @@ services:
replicas: 1
restart_policy:
condition: any
image: drone/drone-runner-docker:1
image: drone/drone-runner-docker:1.5.0
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:

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,7 +1,7 @@
{
"private": true,
"name": "drone",
"version": "0.0.1",
"version": "0.0.4",
"description": "drone ci",
"scripts": {
"deploy": "sh deploy.sh",