Skip to content

Commit 79c40b1

Browse files
authored
Merge pull request #1 from stackhpc/feature/add-dockerfile
Initial code
2 parents f74613b + 2df374c commit 79c40b1

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
tags:
8+
- 'v*'
9+
pull_request:
10+
branches:
11+
- 'master'
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
build-and-push-image:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v3
27+
28+
- name: Log in to the Container registry
29+
uses: docker/login-action@v2
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: Extract metadata (tags, labels) for Docker
36+
id: meta
37+
uses: docker/metadata-action@v4
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
tags: |
41+
# set latest tag for master branch
42+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
43+
- name: Build and push Docker image
44+
uses: docker/build-push-action@v4
45+
with:
46+
context: .
47+
push: ${{ github.event_name != 'pull_request' }}
48+
tags: ${{ steps.meta.outputs.tags }}
49+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM golang:alpine as builder
2+
RUN apk add --no-cache git
3+
RUN git clone https://github.com/jovial/redfish_exporter /build && cd /build && git checkout feature/log_counts
4+
WORKDIR /build
5+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o main .
6+
FROM scratch
7+
COPY --from=builder /build/main /app/
8+
WORKDIR /app
9+
CMD ["./main"]
10+

0 commit comments

Comments
 (0)