1
0
Fork 0

ci: Begin Jenkins build pipeline

master
Dustin 2022-07-31 10:34:02 -05:00
parent 3c5ee6fa00
commit 3bca14132e
5 changed files with 104 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
ui/*.tar.gz

55
ci/Jenkinsfile vendored Normal file
View File

@ -0,0 +1,55 @@
// vim: set sw=4 ts=4 sts=4 et :
// vim: set ft=groovy :
pipeline {
agent {
kubernetes {
yamlFile 'ci/podTemplate.yaml'
}
}
stages {
stage('Build') {
parallel {
stage('Build Backend') {
steps {
container('python') {
dir('svc') {
sh '. ../ci/build-svc.sh'
}
}
}
post {
success {
dir('svc/dist') {
archiveArtifacts 'hudctrl-*'
}
}
}
}
stage('Build Frontend') {
steps {
container('node') {
dir('ui') {
sh '. ../ci/build-ui.sh'
}
}
}
post {
success {
dir('ui') {
archiveArtifacts 'hudctrl-ui.tar.gz'
}
}
failure {
dir('ui/npm_cache/_logs') {
archiveArtifacts '*'
}
}
}
}
}
}
}
}

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

@ -0,0 +1,7 @@
#!/bin/sh -ex
python -m venv .venv
.venv/bin/python -m pip install --no-cache-dir -U pip setuptools wheel
.venv/bin/python -m pip install --no-cache-dir poetry
.venv/bin/poetry build

14
ci/build-ui.sh Normal file
View File

@ -0,0 +1,14 @@
#!/bin/sh -ex
export TEMP="${PWD}/tmp"
mkdir "${TEMP}"
# https://github.com/npm/cli/issues/3208#issuecomment-1002990902
# Work around crazy performance issue in npm@7 / npm@8
mkdir node_modules
npm ci
npm run build
find dist -mindepth 1 -maxdepth 1 -printf '%P\0' \
| xargs -0 tar -czf hudctrl-ui.tar.gz -C dist

27
ci/podTemplate.yaml Normal file
View File

@ -0,0 +1,27 @@
spec:
containers:
- name: python
image: docker.io/python:3.10
command:
- sleep
- infinity
securityContext:
readOnlyRootFilesystem: true
runAsUser: 1000
- name: node
image: docker.io/node:16-bullseye-slim
command:
- sleep
- infinity
env:
- name: npm_config_cache
value: ./npm_cache
- name: NODE_OPTIONS
value: '--max_old_space_size=512'
resources:
limits:
memory: 1G
cpu: 1.0
securityContext:
readOnlyRootFilesystem: true
runAsUser: 1000