ci: Build container image
This image will be used to deploy the application on the Kubernetes cluster.
This commit is contained in:
16
ci/Jenkinsfile
vendored
16
ci/Jenkinsfile
vendored
@@ -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
7
ci/build-container.sh
Normal 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
5
ci/container-common.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
# shellcheck: shell=sh
|
||||
|
||||
tag_name() {
|
||||
echo "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g' -e 's/^[.-]/_/'
|
||||
}
|
||||
@@ -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
17
ci/publish-container.sh
Normal 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
|
||||
Reference in New Issue
Block a user