try task + build

This commit is contained in:
Jason Swank 2024-06-10 22:20:47 -04:00
parent f43022c3e4
commit afe1b6175c
2 changed files with 22 additions and 13 deletions

View File

@ -1,30 +1,24 @@
image: alpine/edge image: alpine/edge
secrets: secrets:
- 0ee986ff-5686-43cd-ac3a-1fe5b2e5dd8f - 0ee986ff-5686-43cd-ac3a-1fe5b2e5dd8f
- f523ee29-5ef8-490f-8903-43ad7c49060b - f523ee29-5ef8-490f-8903-43ad7c49060b
- 130adee5-3a8f-4035-8cad-e3d044be2961 - 130adee5-3a8f-4035-8cad-e3d044be2961
sources: sources:
- https://git.sr.ht/~jswank/alpine-cli - https://git.sr.ht/~jswank/alpine-cli
packages: packages:
- podman - podman
- just - go-task
- runit - runit
tasks: tasks:
# cgroups need to be running in order to run podman # cgroups need to be running in order to run podman
- prep: | - prep: |
sudo rc-service cgroups start sudo rc-service cgroups start
sleep 1 sleep 1
# build the image using the just recipe # build the image using the just recipe
# - sudo (-u root) is required to run podman without more setup # - sudo (-u root) is required to run podman without more setup
- build: | - build: |
cd alpine-cli cd alpine-cli
sudo --preserve-env just build sudo --preserve-env go-task build
# publish the image using the just recipe # publish the image using the just recipe
# - set environment variables from the ~/.envdir directory. see # - set environment variables from the ~/.envdir directory. see
# http://smarden.org/runit/chpst.8.html for details on chpst # http://smarden.org/runit/chpst.8.html for details on chpst
@ -32,6 +26,6 @@ tasks:
# - sudo --preserve-env is required to pass environment variables # - sudo --preserve-env is required to pass environment variables
- publish: | - publish: |
cd alpine-cli cd alpine-cli
chpst -e ~/.envdir sudo --preserve-env just registry_pass_var=GH_PAT publish chpst -e ~/.envdir sudo --preserve-env go-task publish
chpst -e ~/.envdir sudo --preserve-env just registry=docker.io registry_pass_var=DH_PAT publish # chpst -e ~/.envdir sudo --preserve-env just registry=docker.io registry_pass_var=DH_PAT publish
chpst -e ~/.envdir sudo --preserve-env just registry=quay.io registry_pass_var=QUAY_PAT publish # chpst -e ~/.envdir sudo --preserve-env just registry=quay.io registry_pass_var=QUAY_PAT publish

View File

@ -1,8 +1,11 @@
version: '3' version: '3'
env: env:
IMAGE: jswank/alpine-cli IMAGE: jswank/alpine-cli
NAME: alpine-cli NAME: alpine-cli
TAG: latest vars:
TAG:
sh: 'grep ^FROM Dockerfile | cut -d: -f2'
tasks: tasks:
default: default:
cmds: cmds:
@ -13,3 +16,15 @@ tasks:
- (podman manifest exists {{.IMAGE}}:{{.TAG}} && podman manifest rm {{.IMAGE}}:{{.TAG}}) || true - (podman manifest exists {{.IMAGE}}:{{.TAG}} && podman manifest rm {{.IMAGE}}:{{.TAG}}) || true
- podman manifest create {{.IMAGE}}:{{.TAG}} - podman manifest create {{.IMAGE}}:{{.TAG}}
- podman build --platform linux/amd64,linux/arm64 --manifest {{.IMAGE}}:{{.TAG}} {{.CLI_ARGS}} -f Dockerfile ctx - podman build --platform linux/amd64,linux/arm64 --manifest {{.IMAGE}}:{{.TAG}} {{.CLI_ARGS}} -f Dockerfile ctx
publish:
desc: publish the image
cmds:
- podman tag {{.IMAGE}}:{{.TAG}} {{.REGISTRY}}/{{.IMAGE}}:{{.ALT_TAG}}
- echo "${{.REGISTRY_PASS_VAR}}" | podman login {{.REGISTRY}} -u {{.REGISTRY_USER}} --password-stdin
- podman manifest push {{.REGISTRY}}/{{.IMAGE}}:{{.ALT_TAG}}
- podman logout {{.REGISTRY}}
vars:
REGISTRY_PASS_VAR: GH_PAT
REGISTRY: ghcr.io
REGISTRY_USER: jswank
ALT_TAG: '{{.TAG}}'