Merge branch 'home-deploy' into remote
continuous-integration/drone/push Build was killed Details

This commit is contained in:
Giles Bradshaw 2020-04-27 18:59:51 +01:00
commit e7829c2a45
6 changed files with 162 additions and 74 deletions

View File

@ -13,69 +13,9 @@ load("@this//:public-secrets.star", "publicSecrets")
load("@this//:secret-secrets.star", "secretSecrets") load("@this//:secret-secrets.star", "secretSecrets")
load("@this//:pull.star", "pull") load("@this//:pull.star", "pull")
load("@this//:deploy.star", "deploy") load("@this//:deploy.star", "deploy")
load("@this//:build-folder.star", "buildFolder")
def buildHome(): load("@this//:build-docker-folder.star", "buildDockerFolder")
return { load("@this//:pipeline.star", "pipeline")
"name": "build-nginx-home",
"image": "docker:dind",
"volumes": [
{
"name": "dockersock",
"path": "/var/run",
},
],
"environment": environment([
"local-docker-registry",
]),
"commands": [
"cd letsencrypt-nginx",
"sh build.home.sh $${{LOCAL_DOCKER_REGISTRY}}".format(),
],
}
def pipeline(name, steps, dependsOn):
return {
"kind": "pipeline",
"name": name,
"depends_on": dependsOn,
"steps": [
printSecrets(
"env-stack",
publicSecrets,
secretSecrets,
),
wait(15, "wait"),
] + steps,
"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": "/home/giles/gitea-drone-stack/.ca",
},
},
],
}
def main(ctx): def main(ctx):
if ctx.build.branch == 'home-deploy': if ctx.build.branch == 'home-deploy':
@ -83,16 +23,59 @@ def main(ctx):
pipeline( pipeline(
'home-deploy', 'home-deploy',
[ [
#build("guacamole-postgresql"), printSecrets(
#build("ngrok-gitea"), "env-stack",
#build("letsencrypt-nginx"), publicSecrets,
secretSecrets,
),
wait(15, "wait"),
build("guacamole-postgresql"),
build("ngrok-gitea"),
build("letsencrypt-nginx"),
build("drone-starlark"), build("drone-starlark"),
#buildHome(), buildDockerFolder(
#buildNginx("blog"), "Dockerfile.home",
#buildNginx("drone"), "nginx:latest",
#buildNginx("git"), "$${LOCAL_DOCKER_REGISTRY}home",
#buildNginx("remote"), "letsencrypt-nginx",
#buildNginx("chat"), "home",
),
buildDockerFolder(
"Dockerfile.blog",
"$${LOCAL_DOCKER_REGISTRY}letsencrypt-nginx",
"$${LOCAL_DOCKER_REGISTRY}letsencrypt-blog",
"letsencrypt-nginx",
"blog",
),
buildDockerFolder(
"Dockerfile.drone",
"$${LOCAL_DOCKER_REGISTRY}letsencrypt-nginx",
"$${LOCAL_DOCKER_REGISTRY}letsencrypt-drone",
"letsencrypt-nginx",
"drone",
),
buildDockerFolder(
"Dockerfile.git",
"$${LOCAL_DOCKER_REGISTRY}letsencrypt-nginx",
"$${LOCAL_DOCKER_REGISTRY}letsencrypt-git",
"letsencrypt-nginx",
"git",
),
buildDockerFolder(
"Dockerfile.remote",
"$${LOCAL_DOCKER_REGISTRY}letsencrypt-nginx",
"$${LOCAL_DOCKER_REGISTRY}letsencrypt-remote",
"letsencrypt-nginx",
"remote",
),
buildDockerFolder(
"Dockerfile.chat",
"$${LOCAL_DOCKER_REGISTRY}letsencrypt-nginx",
"$${LOCAL_DOCKER_REGISTRY}letsencrypt-chat",
"letsencrypt-nginx",
"chat",
),
scp("~/gitea-drone-stack"), scp("~/gitea-drone-stack"),
pull([ pull([
"letsencrypt-git", "letsencrypt-git",
@ -100,7 +83,7 @@ def main(ctx):
"letsencrypt-drone", "letsencrypt-drone",
"letsencrypt-remote", "letsencrypt-remote",
"letsencrypt-blog", "letsencrypt-blog",
"nginx-home1", "home",
"drone-starlark", "drone-starlark",
]), ]),
deploy( deploy(

View File

@ -347,7 +347,7 @@ services:
replicas: 1 replicas: 1
restart_policy: restart_policy:
condition: any condition: any
image: ${LOCAL_DOCKER_REGISTRY}nginx-home1 image: ${LOCAL_DOCKER_REGISTRY}home
environment: environment:
- SERVER_NAME=${BLOG_DOMAIN} - SERVER_NAME=${BLOG_DOMAIN}
ports: ports:

View File

@ -0,0 +1,31 @@
load("@this//:environment.star", "environment")
def buildDockerFolder(
dockerFile,
image,
tag,
folder,
name,
):
return {
"name": "build-{name}".format(
name = name,
),
"image": "docker:dind",
"volumes": [
{
"name": "dockersock",
"path": "/var/run",
},
],
"environment": environment([
"local-docker-registry",
]),
"commands": [
"cd {folder}".format(folder=folder),
"sh build-docker-folder.sh {dockerFile} {image} {tag}".format(
image = image,
dockerFile = dockerFile,
tag = tag,
),
],
}

View File

@ -0,0 +1,31 @@
load("@this//:environment.star", "environment")
def buildDockerFolder(
dockerFile,
image,
tag,
folder,
name,
):
return {
"name": "build-{name}".format(
name = name,
),
"image": "docker:dind",
"volumes": [
{
"name": "dockersock",
"path": "/var/run",
},
],
"environment": environment([
"local-docker-registry",
]),
"commands": [
"cd {folder}".format(folder=folder),
"sh build-docker-folder.sh {dockerFile} {image} {tag}".format(
image = image,
dockerFile = dockerFile,
tag = tag,
),
],
}

View File

@ -0,0 +1,40 @@
def pipeline(
name,
steps,
dependsOn,
):
return {
"kind": "pipeline",
"name": name,
"depends_on": dependsOn,
"steps": steps,
"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": "/home/giles/gitea-drone-stack/.ca",
},
},
],
}

View File

@ -0,0 +1,3 @@
set -e
docker build . -f $1 --build-arg image=$2 -t $3
docker push $3