add docker build
All checks were successful
Github Actions Demo / Explore-Gitea-Actions (push) Successful in 5s

This commit is contained in:
James Andariese 2024-03-02 11:07:02 -06:00
parent a083da5efd
commit 7ffd3ffaab
2 changed files with 34 additions and 0 deletions

19
.github/workflows/build.yaml vendored Normal file
View File

@ -0,0 +1,19 @@
name: Github Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions (on Gitea) 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: metal-docker
steps:
- name: Check out repository code
uses: actions/checkout@v3
- run: |
REPO_BASE=${REPO_BASE_OVERRIDE-${GITHUB_SERVER_URL-https://github.com}}
docker build --progress plain --label "org.opencontainers.image.source=$REPO_BASE/$GITHUB_REPOSITORY" --iidfile iid.txt .
stringprefix() { [ ${#1} -le $2 ] && echo $1 && return 0 || stringprefix "${1%?}" $2 ; }
SHORTSHA="$(stringprefix "$GITHUB_SHA" 8)"
for TAG in "$SHORTSHA" "$GITHUB_REF_NAME";do
docker tag "`cat iid.txt`" "$DOCKER_REGISTRY/$GITHUB_REPOSITORY:$TAG"
docker push "$DOCKER_REGISTRY/$GITHUB_REPOSITORY:$TAG"
done

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM golang:1.21 AS build
WORKDIR /ipfs-key
ADD go.mod go.sum /ipfs-key
RUN echo 'package main;func main() {}' > main.go
RUN go get && rm main.go
ADD main.go /ipfs-key
RUN go build
FROM scratch
COPY --from=build /ipfs-key/ipfs-key /ipfs-key
ENTRYPOINT /ipfs-key