From 8714d13bf6cb0d1099361b06e28d97c4f35a99e0 Mon Sep 17 00:00:00 2001 From: Will Szumski Date: Thu, 27 Apr 2023 16:46:54 +0100 Subject: [PATCH 1/2] Add dockerfile --- Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1ac9f52 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM golang:alpine as builder +RUN apk add --no-cache git +RUN git clone https://github.com/jovial/redfish_exporter /build && cd /build && git checkout feature/log_counts +WORKDIR /build +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o main . +FROM scratch +COPY --from=builder /build/main /app/ +WORKDIR /app +CMD ["./main"] + From 2df374c46bd631cfa666061d098e8ef613e977a3 Mon Sep 17 00:00:00 2001 From: Will Szumski Date: Thu, 27 Apr 2023 16:49:49 +0100 Subject: [PATCH 2/2] Add github workflow Taken from: https://github.com/stackhpc/docker-rally/commit/9b038a21db86d8176eb9d9517abc08dd84827305 Co-authored-by: Tyler Christie --- .github/workflows/build-and-push-images.yml | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/build-and-push-images.yml diff --git a/.github/workflows/build-and-push-images.yml b/.github/workflows/build-and-push-images.yml new file mode 100644 index 0000000..2f0e01d --- /dev/null +++ b/.github/workflows/build-and-push-images.yml @@ -0,0 +1,49 @@ +name: Create and publish a Docker image + +on: + push: + branches: + - 'master' + tags: + - 'v*' + pull_request: + branches: + - 'master' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + # set latest tag for master branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}