ci: Build container image

This image will be used to deploy the application on the Kubernetes
cluster.
This commit is contained in:
2022-08-01 18:29:08 -05:00
parent 97f94450c5
commit 6443b64c02
10 changed files with 125 additions and 0 deletions

16
ci/Jenkinsfile vendored
View File

@@ -51,5 +51,21 @@ pipeline {
}
}
}
stage('Build Container') {
steps {
container('podman') {
sh '. ci/build-container.sh'
}
}
}
stage('Publish Container') {
steps {
container('podman') {
sh '. ci/publish-container.sh'
}
}
}
}
}

7
ci/build-container.sh Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/sh -ex
. ci/container-common.sh
cp -r svc/dist container/wheels
cp -r ui/dist container/ui
podman build -t hudctrl:$(tag_name ${BUILD_TAG}) container

5
ci/container-common.sh Normal file
View File

@@ -0,0 +1,5 @@
# shellcheck: shell=sh
tag_name() {
echo "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g' -e 's/^[.-]/_/'
}

View File

@@ -25,3 +25,10 @@ spec:
securityContext:
readOnlyRootFilesystem: true
runAsUser: 1000
- name: podman
image: quay.io/containers/podman:v3.4
command:
- sleep
- infinity
securityContext:
privileged: true

17
ci/publish-container.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/sh -ex
. ci/container-common.sh
push() {
tag=$(tag_name "$1")
podman push hudctrl:$(tag_name ${BUILD_TAG}) registry.pyrocufflink.blue/hudctrl:${tag}
}
push ${BUILD_TAG}
push ${BRANCH_NAME}
if [ "${BRANCH_NAME}" = master ]; then
push latest
fi
if [ -n "${TAG_NAME}" ]; then
push "${TAG_NAME}"
fi