add-hugo-build #5
6 changed files with 23 additions and 23 deletions
|
@ -3,9 +3,9 @@ FROM clojure:lein
|
||||||
# Prepare Entrypoint Script
|
# Prepare Entrypoint Script
|
||||||
ADD resources /tmp
|
ADD resources /tmp
|
||||||
|
|
||||||
ENV BUILD_DIR="/etc/website"
|
ENV BUILDDIR="/etc/website"
|
||||||
ENV SOURCE_DIR="/etc/websitesource"
|
ENV SOURCEDIR="/etc/websitesource"
|
||||||
ENV WEBSITE_ROOT="/var/www/html/website/"
|
ENV WEBSITE_ROOT="/var/www/html/website/"
|
||||||
ENV HASHFILE_DIR="/var/hashfile.d"
|
ENV HASHFILEDIR="/var/hashfile.d"
|
||||||
|
|
||||||
RUN /tmp/install.sh
|
RUN /tmp/install.sh
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
mkdir $BUILD_DIR
|
mkdir $BUILDDIR
|
||||||
mkdir $SOURCE_DIR
|
mkdir $SOURCEDIR
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
@ -11,15 +11,15 @@ filename="website.zip"
|
||||||
hashfilename="hashfile"
|
hashfilename="hashfile"
|
||||||
|
|
||||||
echo "Check for new content"
|
echo "Check for new content"
|
||||||
touch $HASHFILE_DIR/$hashfilename
|
touch $HASHFILEDIR/$hashfilename
|
||||||
currentHash=$( cat $HASHFILE_DIR/$hashfilename )
|
currentHash=$( cat $HASHFILEDIR/$hashfilename )
|
||||||
newHash=$( get-hash-data )
|
newHash=$( get-hash-data )
|
||||||
|
|
||||||
if [[ $currentHash == $newHash ]]
|
if [[ $currentHash == $newHash ]]
|
||||||
then
|
then
|
||||||
echo "Nothing to do"
|
echo "Nothing to do"
|
||||||
else
|
else
|
||||||
echo $currentHash > $HASHFILE_DIR/$hashfilename
|
echo $currentHash > $HASHFILEDIR/$hashfilename
|
||||||
echo "Generate .netrc file"
|
echo "Generate .netrc file"
|
||||||
generate-netrc-file
|
generate-netrc-file
|
||||||
echo "Downloading website data"
|
echo "Downloading website data"
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
function generate-netrc-file() {
|
function generate-netrc-file() {
|
||||||
echo "machine $GIT_HOST password $AUTH_TOKEN" > ~/.netrc
|
echo "machine $GITHOST password $AUTHTOKEN" > ~/.netrc
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-website-data() {
|
function get-website-data() {
|
||||||
curl -H "Authorization: token $AUTH_TOKEN" -o $SOURCE_DIR/$1 $GIT_REPO_URL
|
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$1 $GITREPOURL
|
||||||
}
|
}
|
||||||
|
|
||||||
function get-hash-data() {
|
function get-hash-data() {
|
||||||
curl -s -H "Authorization: token $AUTH_TOKEN" $GIT_COMMIT_URL | jq '.sha'
|
curl -s -H "Authorization: token $AUTHTOKEN" $GITCOMMITURL | jq '.sha'
|
||||||
}
|
}
|
||||||
|
|
||||||
function write-hash-data() {
|
function write-hash-data() {
|
||||||
echo $1 > $HASHFILE_DIR/$2
|
echo $1 > $HASHFILEDIR/$2
|
||||||
}
|
}
|
||||||
|
|
||||||
function unzip-website-data() {
|
function unzip-website-data() {
|
||||||
unzip $SOURCE_DIR/$1 -d $BUILD_DIR
|
unzip $SOURCEDIR/$1 -d $BUILDDIR
|
||||||
}
|
}
|
||||||
|
|
||||||
function build-website() {
|
function build-website() {
|
||||||
(cd $BUILD_DIR; dir=$(ls); cd $dir; ./generate.sh;)
|
(cd $BUILDDIR; dir=$(ls); cd $dir; ./generate.sh;)
|
||||||
}
|
}
|
||||||
|
|
||||||
function move-website-files-to-target() {
|
function move-website-files-to-target() {
|
||||||
(cd $BUILD_DIR; dir=$(ls); cd $dir; rsync -ru --exclude-from "/etc/exclude.pattern" --delete target/html/* $WEBSITE_ROOT;)
|
(cd $BUILDDIR; dir=$(ls); cd $dir; rsync -ru --exclude-from "/etc/exclude.pattern" --delete target/html/* $WEBSITE_ROOT;)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@ metadata:
|
||||||
labels:
|
labels:
|
||||||
app.kubernetes.part-of: NAME-website
|
app.kubernetes.part-of: NAME-website
|
||||||
data:
|
data:
|
||||||
GIT_HOST: GITHOST
|
GITHOST: GITHOST
|
||||||
GIT_REPO_URL: REPOURL
|
GITREPOURL: REPOURL
|
||||||
GIT_COMMIT_URL: COMMITURL
|
GITCOMMITURL: COMMITURL
|
|
@ -6,4 +6,4 @@ metadata:
|
||||||
labels:
|
labels:
|
||||||
app.kubernetes.part-of: NAME-website
|
app.kubernetes.part-of: NAME-website
|
||||||
data:
|
data:
|
||||||
AUTH_TOKEN: TOKEN
|
AUTHTOKEN: TOKEN
|
||||||
|
|
|
@ -236,9 +236,9 @@
|
||||||
:namespace "test-io",
|
:namespace "test-io",
|
||||||
:labels {:app.kubernetes.part-of "test-io-website"}},
|
:labels {:app.kubernetes.part-of "test-io-website"}},
|
||||||
:data
|
:data
|
||||||
{:GIT_HOST "mygit.de"
|
{:GITHOST "mygit.de"
|
||||||
:GIT_REPO_URL "https://mygit.de/api/v1/repos/someuser/repo/archive/main.zip"
|
:GITREPOURL "https://mygit.de/api/v1/repos/someuser/repo/archive/main.zip"
|
||||||
:GIT_COMMIT_URL "https://mygit.de/api/v1/repos/someuser/repo/git/commits/HEAD"}}
|
:GITCOMMITURL "https://mygit.de/api/v1/repos/someuser/repo/git/commits/HEAD"}}
|
||||||
(cut/generate-build-configmap {:issuer "staging"
|
(cut/generate-build-configmap {:issuer "staging"
|
||||||
:build-cpu-request "500m"
|
:build-cpu-request "500m"
|
||||||
:build-cpu-limit "1700m"
|
:build-cpu-limit "1700m"
|
||||||
|
@ -260,7 +260,7 @@
|
||||||
:namespace "test-io",
|
:namespace "test-io",
|
||||||
:labels {:app.kubernetes.part-of "test-io-website"}},
|
:labels {:app.kubernetes.part-of "test-io-website"}},
|
||||||
:data
|
:data
|
||||||
{:AUTH_TOKEN "YWJlZGpnYmFzZG9kag=="}}
|
{:AUTHTOKEN "YWJlZGpnYmFzZG9kag=="}}
|
||||||
(cut/generate-build-secret {:unique-name "test.io",
|
(cut/generate-build-secret {:unique-name "test.io",
|
||||||
:authtoken "abedjgbasdodj"}))))
|
:authtoken "abedjgbasdodj"}))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue