diff options
author | Julien Dessaux | 2022-09-11 21:03:38 +0200 |
---|---|---|
committer | Julien Dessaux | 2022-09-12 21:39:39 +0200 |
commit | 46af7df8fa7fed1589bb91e20bd4619514c88b75 (patch) | |
tree | 1cf332f137420f0ae9701643880a17b052dce95d | |
parent | Added mirror to github script and job (diff) | |
download | ev-scripts-46af7df8fa7fed1589bb91e20bd4619514c88b75.tar.gz ev-scripts-46af7df8fa7fed1589bb91e20bd4619514c88b75.tar.bz2 ev-scripts-46af7df8fa7fed1589bb91e20bd4619514c88b75.zip |
Added www scripts and job
Diffstat (limited to '')
-rwxr-xr-x | www/build-images.sh | 75 | ||||
-rw-r--r-- | www/www-deploy.yaml | 30 |
2 files changed, 105 insertions, 0 deletions
diff --git a/www/build-images.sh b/www/build-images.sh new file mode 100755 index 0000000..632cd3e --- /dev/null +++ b/www/build-images.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +set -euo pipefail + +NAME=$1 + +WORKDIR="/tmp/${NAME}" + +cleanup() { + rm -rf "${WORKDIR}" +} + +trap cleanup EXIT + +ret=0; buildah images adyxax/alpine &>/dev/null || ret=$? +if [[ "${ret}" != 0 ]]; then + buildah rmi --all + ALPINE_LATEST=$(curl --silent https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/ | + perl -lane '$latest = $1 if $_ =~ /^<a href="(alpine-minirootfs-\d+\.\d+\.\d+-x86_64\.tar\.gz)">/; END {print $latest}' + ) + if [ ! -e "./${ALPINE_LATEST}" ]; then + echo "Fetching ${ALPINE_LATEST}..." + curl --silent "https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/${ALPINE_LATEST}" \ + --output "./${ALPINE_LATEST}" + fi + + ctr=$(buildah from scratch) + buildah add "${ctr}" "${ALPINE_LATEST}" / + buildah run "${ctr}" /bin/sh -c 'apk upgrade --no-cache' + buildah run "${ctr}" /bin/sh -c 'apk add --no-cache pcre sqlite-libs' + buildah commit "${ctr}" adyxax/alpine + buildah rm "${ctr}" +fi + +ret=0; buildah images adyxax/hugo &>/dev/null || ret=$? +if [[ "${ret}" != 0 ]]; then + hugo=$(buildah from adyxax/alpine) + buildah run "${hugo}" /bin/sh -c 'apk add --no-cache go git hugo make' + buildah commit "${hugo}" adyxax/hugo +else + hugo=$(buildah from adyxax/hugo) +fi + +buildah run -v "${WORKDIR}":/www "${hugo}" -- sh -c 'cd /www; make build' +buildah rm "${hugo}" + +ret=0; buildah images adyxax/nginx &>/dev/null || ret=$? +if [[ "${ret}" != 0 ]]; then + nginx=$(buildah from adyxax/alpine) + buildah run "${nginx}" /bin/sh -c 'apk add --no-cache nginx' + buildah commit "${nginx}" adyxax/nginx +else + nginx=$(buildah from adyxax/nginx) +fi + +(cd "${WORKDIR}/deploy" && buildah copy "${nginx}" nginx.conf headers_secure.conf headers_static.conf /etc/nginx/) +buildah config \ + --author 'Julien Dessaux' \ + --cmd nginx \ + --port 80 \ + "${nginx}" +(cd "${WORKDIR}" && buildah copy "${nginx}" public /var/www/www.adyxax.org) +buildah commit "${nginx}" adyxax/www +buildah rm "${nginx}" + +ctr=$(buildah from scratch) +(cd "${WORKDIR}" && buildah copy "${ctr}" search/search /) +buildah config \ + --author 'Julien Dessaux' \ + --cmd /search \ + --port 8080 \ + "${ctr}" +buildah commit "${ctr}" adyxax/www-search +buildah rm "${ctr}" + +trap - EXIT diff --git a/www/www-deploy.yaml b/www/www-deploy.yaml new file mode 100644 index 0000000..980bf87 --- /dev/null +++ b/www/www-deploy.yaml @@ -0,0 +1,30 @@ +name: "www-deploy" +steps: + - label: git clone + script: + path: "../common/git-clone.sh" + arguments: + - "www-deploy" + - "https://git.adyxax.org/adyxax/www" + - label: build images + script: + path: "build-images.sh" + arguments: + - "www-deploy" + - label: make push + script: + path: "../common/make.sh" + arguments: + - "www-deploy" + - "push" + - label: clean + script: + path: "../common/clean.sh" + arguments: + - "www-deploy" +runner: + identity: "ssh-myth" + name: "ssh" + parameters: + host: "myth.adyxax.org" + user: "root" |