Bel LaPointe 2025-10-06 07:21:05 -06:00
parent 3c60633723
commit a17676472b
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,19 @@
name: cicd
on:
push:
branches:
- main
paths:
- '.gitea/**'
- 'srv/**'
jobs:
ci:
name: ci
runs-on: dind
steps:
- name: checkout
uses: actions/checkout@v3
- name: ci
run: |
bash ./srv/build.sh

11
srv/Dockerfile Normal file
View File

@ -0,0 +1,11 @@
FROM golang:1.23.9-alpine3.21 as builder
COPY ./ /go/src/25-bday-qt
WORKDIR /go/src/25-bday-qt
RUN cd ./srv; go build -o /go/bin/25-bday-qt
FROM alpine:3.18.4
COPY --from=builder /go/bin/25-bday-qt /bin/
CMD []
ENTRYPOINT ["/bin/25-bday-qt"]

14
srv/build.sh Normal file
View File

@ -0,0 +1,14 @@
#! /bin/bash
set -e
img=registry-app.inhome.blapointe.com:5001/bel/25-bday-qt:${1:-$(date +%Y%m%d%H%M)}
cd "$(dirname "$(dirname "$(realpath "$BASH_SOURCE")")")"
was=$(docker inspect $img | jq -r .[0].Id | sed 's/^sha256://')
docker build -f ./srv/Dockerfile -t $img .
now=$(docker inspect $img | jq -r .[0].Id | sed 's/^sha256://')
docker push $img
if [ -n "$was" ] && [ "$was" != "$now" ] && docker inspect "$was" &> /dev/null; then
docker rmi "$was" || true
docker rmi $(docker ps | grep ${img%:*} | grep '<none>' | awk '{print $3}') || true
fi