[Skip-Ci] Update Docker image, cron job, tests
It seems, timeout sends signals that do not stop the server process. Set the signal to SIGKILL - which also kills the function.sh process. Thus moved the last function to entrypoint.sh
This commit is contained in:
parent
bcad22b067
commit
46f0c72c3e
8 changed files with 39 additions and 30 deletions
|
@ -3,10 +3,8 @@ FROM clojure:lein
|
|||
# Prepare Entrypoint Script
|
||||
ADD resources /tmp
|
||||
|
||||
ENV BUILDDIR="website"
|
||||
ENV SOURCEDIR="/etc/websitesource"
|
||||
ENV BUILDDIR="/etc/website"
|
||||
ENV WEBSITEROOT="/var/www/html/website/"
|
||||
|
||||
RUN /tmp/install.sh
|
||||
#RUN /tmp/entrypoint.sh
|
||||
|
||||
# ToDo: lein not working on clojure image?
|
|
@ -1,14 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
mkdir $BUILDDIR
|
||||
mkdir $SOURCEDIR
|
||||
|
||||
source /usr/local/bin/functions.sh
|
||||
|
||||
function main() {
|
||||
get-and-unzip-website-data
|
||||
build-and-extract-website
|
||||
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 resources/public/* $WEBSITEROOT;)
|
||||
}
|
||||
|
||||
main
|
||||
echo "Downloading website"
|
||||
get-and-unzip-website-data
|
||||
echo "Building website"
|
||||
build-and-extract-website
|
||||
echo "Moving files"
|
||||
move-website-files-to-target
|
||||
|
||||
while true; do
|
||||
sleep 1m
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
function get-and-unzip-website-data() {
|
||||
curl -H "Authorization: token $AUTHTOKEN" -O $GITREPOURL # GITREPURL = https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/main.zip
|
||||
mkdir $BUILDDIR
|
||||
unzip main.zip -D $BUILDDIR
|
||||
filename="website.zip"
|
||||
curl -H "Authorization: token $AUTHTOKEN" -o $SOURCEDIR/$filename $GITREPOURL # GITREPURL = https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/main.zip
|
||||
unzip $SOURCEDIR/$filename -d $BUILDDIR
|
||||
}
|
||||
|
||||
function build-and-extract-website() {
|
||||
(cd $BUILDDIR; lein ring war; websiteartifactname=$(ls | grep -o *.war); unzip target/$websiteartifactname "WEB-INF/classes/public/*")
|
||||
}
|
||||
|
||||
# set variables from environment
|
||||
# read write zugriff sicherstellen
|
||||
function move-website-files-to-target() {
|
||||
rsync -ru --exclude-from "/etc/exclude.pattern" --delete WEB-INF/classes/public/* $TARGETDIR
|
||||
(cd $BUILDDIR; dir=$(ls); cd $dir; timeout -s SIGKILL 35s lein ring server-headless;)
|
||||
# websiteartifactname=$(ls target/ | grep -Eo "*.+\.war"); unzip target/$websiteartifactname
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
(def config? (s/keys :req-un [::fqdn]
|
||||
:opt-un [::issuer]))
|
||||
|
||||
(def auth? (s/keys :req-un [::token ::url]))
|
||||
(def auth? (s/keys :req-un [::authtoken ::gitrepourl]))
|
||||
|
||||
(def vol? (s/keys :req-un [::volume-total-storage-size
|
||||
::number-of-websites]))
|
||||
|
@ -125,14 +125,16 @@
|
|||
(let [{:keys [fqdn]} config]
|
||||
(->
|
||||
(yaml/load-as-edn "website/website-build-cron.yaml")
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn fqdn)))))
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn fqdn))
|
||||
(cm/replace-all-matching-values-by-new-value "FQDN" fqdn))))
|
||||
|
||||
(defn-spec generate-website-build-deployment pred/map-or-seq?
|
||||
[config config?]
|
||||
(let [{:keys [fqdn]} config]
|
||||
(->
|
||||
(yaml/load-as-edn "website/website-build-deployment.yaml")
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn fqdn)))))
|
||||
(replace-all-matching-subvalues-in-string-start "NAME" (unique-name-from-fqdn fqdn))
|
||||
(cm/replace-all-matching-values-by-new-value "FQDN" fqdn))))
|
||||
|
||||
(defn-spec generate-website-build-secret pred/map-or-seq?
|
||||
[auth auth?]
|
||||
|
|
|
@ -44,7 +44,7 @@ spec:
|
|||
emptyDir: {}
|
||||
- name: website-content-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: NAME-content-pvc
|
||||
claimName: NAME-content-volume
|
||||
- name: website-cert
|
||||
secret:
|
||||
secretName: NAME-cert
|
||||
|
|
|
@ -5,7 +5,7 @@ metadata:
|
|||
labels:
|
||||
app.kubernetes.part-of: website # correct name?
|
||||
spec:
|
||||
schedule: "10 23 * * *"
|
||||
schedule: "1,7,14,21,28,35,42,49,54,59 * * * *"
|
||||
successfulJobsHistoryLimit: 1
|
||||
failedJobsHistoryLimit: 1
|
||||
jobTemplate:
|
||||
|
@ -17,6 +17,9 @@ spec:
|
|||
name: NAME-build-app
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["/entrypoint.sh"]
|
||||
env:
|
||||
- name: HOSTADRESS
|
||||
value: FQDN
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: NAME-secret
|
||||
|
@ -26,5 +29,5 @@ spec:
|
|||
volumes:
|
||||
- name: content-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: NAME-content-pvc
|
||||
claimName: NAME-content-volume
|
||||
restartPolicy: OnFailure
|
|
@ -21,6 +21,9 @@ spec:
|
|||
name: NAME-build-app
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["/entrypoint.sh"]
|
||||
env:
|
||||
- name: HOSTADRESS
|
||||
value: FQDN
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: NAME-secret
|
||||
|
@ -30,4 +33,4 @@ spec:
|
|||
volumes:
|
||||
- name: content-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: NAME-content-pvc
|
||||
claimName: NAME-content-volume
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
{:key "website.conf", :path "conf.d/website.conf"}
|
||||
{:key "mime.types", :path "mime.types"}]}}
|
||||
{:name "log", :emptyDir {}}
|
||||
{:name "website-content-volume", :persistentVolumeClaim {:claimName "test-de-content-pvc"}}
|
||||
{:name "website-content-volume", :persistentVolumeClaim {:claimName "test-de-content-volume"}}
|
||||
{:name "website-cert",
|
||||
:secret
|
||||
{:secretName "test-de-cert", :items [{:key "tls.crt", :path "tls.crt"} {:key "tls.key", :path "tls.key"}]}}]}}}}
|
||||
|
@ -94,7 +94,7 @@
|
|||
:kind "CronJob",
|
||||
:metadata {:name "test-de-build-cron", :labels {:app.kubernetes.part-of "website"}},
|
||||
:spec
|
||||
{:schedule "10 23 * * *",
|
||||
{:schedule "1,7,14,21,28,35,42,49,54,59 * * * *",
|
||||
:successfulJobsHistoryLimit 1,
|
||||
:failedJobsHistoryLimit 1,
|
||||
:jobTemplate
|
||||
|
@ -106,9 +106,10 @@
|
|||
:name "test-de-build-app",
|
||||
:imagePullPolicy "IfNotPresent",
|
||||
:command ["/entrypoint.sh"],
|
||||
:env [{:name "HOSTADRESS", :value "test.de"}],
|
||||
:envFrom [{:secretRef {:name "test-de-secret"}}],
|
||||
:volumeMounts [{:name "content-volume", :mountPath "/var/www/html/website"}]}],
|
||||
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "test-de-content-pvc"}}],
|
||||
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "test-de-content-volume"}}],
|
||||
:restartPolicy "OnFailure"}}}}}}
|
||||
(cut/generate-website-build-cron {:fqdn "test.de"}))))
|
||||
|
||||
|
@ -129,9 +130,10 @@
|
|||
:name "test-de-build-app",
|
||||
:imagePullPolicy "IfNotPresent",
|
||||
:command ["/entrypoint.sh"],
|
||||
:env [{:name "HOSTADRESS", :value "test.de"}],
|
||||
:envFrom [{:secretRef {:name "test-de-secret"}}],
|
||||
:volumeMounts [{:name "content-volume", :mountPath "/var/www/html/website"}]}],
|
||||
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "test-de-content-pvc"}}]}}}}
|
||||
:volumes [{:name "content-volume", :persistentVolumeClaim {:claimName "test-de-content-volume"}}]}}}}
|
||||
(cut/generate-website-build-deployment {:fqdn "test.de"}))))
|
||||
|
||||
(deftest should-generate-website-build-secret
|
||||
|
|
Loading…
Reference in a new issue