From df736e05780ea0438847ef3e059315e9d1cdeb03 Mon Sep 17 00:00:00 2001 From: James Andariese Date: Sat, 2 Mar 2024 11:07:02 -0600 Subject: [PATCH] add docker build --- .github/workflows/build.yaml | 19 +++++++++++++++++++ Dockerfile | 16 ++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/build.yaml create mode 100644 Dockerfile diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..bac51a2 --- /dev/null +++ b/.github/workflows/build.yaml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4539f9f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM golang:1.21-alpine 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 alpine:3.19 + +COPY --from=build /ipfs-key/ipfs-key /bin/ipfs-key + +ENTRYPOINT ["/bin/ipfs-key"] +CMD []