renamed env variables according to convention

This commit is contained in:
Clemens 2024-03-07 12:19:28 +01:00
parent ebca7a3454
commit 164f66d4b7
6 changed files with 22 additions and 22 deletions

View file

@ -3,9 +3,9 @@ FROM clojure:lein
# Prepare Entrypoint Script # Prepare Entrypoint Script
ADD resources /tmp ADD resources /tmp
ENV BUILDDIR="/etc/website" ENV BUILD_DIR="/etc/website"
ENV SOURCEDIR="/etc/websitesource" ENV SOURCE_DIR="/etc/websitesource"
ENV WEBSITEROOT="/var/www/html/website/" ENV WEBSITE_ROOT="/var/www/html/website/"
ENV HASHFILEDIR="/var/hashfile.d" ENV HASHFILE_DIR="/var/hashfile.d"
RUN /tmp/install.sh RUN /tmp/install.sh

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
mkdir $BUILDDIR mkdir $BUILD_DIR
mkdir $SOURCEDIR mkdir $SOURCE_DIR
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 $HASHFILEDIR/$hashfilename touch $HASHFILE_DIR/$hashfilename
currentHash=$( cat $HASHFILEDIR/$hashfilename ) currentHash=$( cat $HASHFILE_DIR/$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 > $HASHFILEDIR/$hashfilename echo $currentHash > $HASHFILE_DIR/$hashfilename
echo "Generate .netrc file" echo "Generate .netrc file"
generate-netrc-file generate-netrc-file
echo "Downloading website data" echo "Downloading website data"

View file

@ -1,29 +1,29 @@
#!/bin/bash #!/bin/bash
function generate-netrc-file() { function generate-netrc-file() {
echo "machine $GIT_HOST password $AUTHTOKEN" > ~/.netrc echo "machine $GIT_HOST password $AUTH_TOKEN" > ~/.netrc
} }
function get-website-data() { function get-website-data() {
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$1 $GITREPOURL curl -H "Authorization: token $AUTH_TOKEN" -o $SOURCE_DIR/$1 $GIT_REPO_URL
} }
function get-hash-data() { function get-hash-data() {
curl -s -H "Authorization: token $AUTHTOKEN" $GITCOMMITURL | jq '.sha' curl -s -H "Authorization: token $AUTH_TOKEN" $GIT_COMMIT_URL | jq '.sha'
} }
function write-hash-data() { function write-hash-data() {
echo $1 > $HASHFILEDIR/$2 echo $1 > $HASHFILE_DIR/$2
} }
function unzip-website-data() { function unzip-website-data() {
unzip $SOURCEDIR/$1 -d $BUILDDIR unzip $SOURCE_DIR/$1 -d $BUILD_DIR
} }
function build-website() { function build-website() {
(cd $BUILDDIR; dir=$(ls); cd $dir; ./generate.sh;) (cd $BUILD_DIR; dir=$(ls); cd $dir; ./generate.sh;)
} }
function move-website-files-to-target() { function move-website-files-to-target() {
(cd $BUILDDIR; dir=$(ls); cd $dir; rsync -ru --exclude-from "/etc/exclude.pattern" --delete target/html/* $WEBSITEROOT;) (cd $BUILD_DIR; dir=$(ls); cd $dir; rsync -ru --exclude-from "/etc/exclude.pattern" --delete target/html/* $WEBSITE_ROOT;)
} }

View file

@ -7,5 +7,5 @@ metadata:
app.kubernetes.part-of: NAME-website app.kubernetes.part-of: NAME-website
data: data:
GIT_HOST: GITHOST GIT_HOST: GITHOST
GITREPOURL: REPOURL GIT_REPO_URL: REPOURL
GITCOMMITURL: COMMITURL GIT_COMMIT_URL: COMMITURL

View file

@ -6,4 +6,4 @@ metadata:
labels: labels:
app.kubernetes.part-of: NAME-website app.kubernetes.part-of: NAME-website
data: data:
AUTHTOKEN: TOKEN AUTH_TOKEN: TOKEN

View file

@ -237,8 +237,8 @@
:labels {:app.kubernetes.part-of "test-io-website"}}, :labels {:app.kubernetes.part-of "test-io-website"}},
:data :data
{:GIT_HOST "mygit.de" {:GIT_HOST "mygit.de"
:GITREPOURL "https://mygit.de/api/v1/repos/someuser/repo/archive/main.zip" :GIT_REPO_URL "https://mygit.de/api/v1/repos/someuser/repo/archive/main.zip"
:GITCOMMITURL "https://mygit.de/api/v1/repos/someuser/repo/git/commits/HEAD"}} :GIT_COMMIT_URL "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
{:AUTHTOKEN "YWJlZGpnYmFzZG9kag=="}} {:AUTH_TOKEN "YWJlZGpnYmFzZG9kag=="}}
(cut/generate-build-secret {:unique-name "test.io", (cut/generate-build-secret {:unique-name "test.io",
:authtoken "abedjgbasdodj"})))) :authtoken "abedjgbasdodj"}))))