Skip to content

Commit

Permalink
Merge pull request #1 from stackhpc/feature/add-dockerfile
Browse files Browse the repository at this point in the history
Initial code
  • Loading branch information
jovial authored Apr 27, 2023
2 parents f74613b + 2df374c commit 79c40b1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build-and-push-images.yml
Original file line number Diff line number Diff line change
@@ -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 }}
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 79c40b1

Please sign in to comment.