54 lines
1.4 KiB
Bash
54 lines
1.4 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
task="$root/catalog/maidn-node-runtime-image.yaml"
|
|
|
|
contains() {
|
|
grep -qF -- "$1" "$task"
|
|
}
|
|
|
|
for value in \
|
|
'apiVersion: tekton.dev/v1' \
|
|
'kind: Task' \
|
|
'name: maidn-node-runtime-image' \
|
|
'emptyDir: {}' \
|
|
'forgejo-git-credentials' \
|
|
'forgejo-registry-credentials' \
|
|
'case "$REPOSITORY_URL" in https://git.pingu.pw/*)' \
|
|
'case "$REVISION" in [A-Za-z0-9]*)' \
|
|
'case "$IMAGE" in git.pingu.pw/*)' \
|
|
'GIT_ASKPASS=/work/askpass' \
|
|
'runAsNonRoot: true' \
|
|
'allowPrivilegeEscalation: false' \
|
|
'drop: [ALL]' \
|
|
'type: RuntimeDefault' \
|
|
'npm install --ignore-scripts --no-audit --no-fund --package-lock=false' \
|
|
'memory: 256Mi' \
|
|
'memory: 512Mi' \
|
|
'computeResources:' \
|
|
'npm run build' \
|
|
'npm prune --omit=dev --ignore-scripts --no-audit --no-fund' \
|
|
'cp package.json /work/layer/app/' \
|
|
'cp -R node_modules dist /work/layer/app/' \
|
|
'tar -C /work/layer -cf /work/layer.tar app' \
|
|
'--base=node:22-alpine' \
|
|
'--new_tag=$(params.image):$(params.revision)' \
|
|
'- mutate' \
|
|
'--entrypoint=node' \
|
|
'--cmd=dist/index.js' \
|
|
'--workdir=/app' \
|
|
'--user=node' \
|
|
'--env=PORT=8080' \
|
|
'--exposed-ports=8080/tcp' \
|
|
'--tag=$(params.image):$(params.revision)'; do
|
|
contains "$value"
|
|
done
|
|
|
|
for param in url revision image; do
|
|
contains "name: $param"
|
|
done
|
|
|
|
! grep -qiE 'kaniko|privileged: true' "$task"
|
|
! grep -q '^[[:space:]]*resources:' "$task"
|