Skip to content

Commit bc81514

Browse files
authored
feat: support to publish new-dockerfile as image (#12)
Co-authored-by: rick <[email protected]>
1 parent 7488c69 commit bc81514

File tree

4 files changed

+73
-2
lines changed

4 files changed

+73
-2
lines changed

.github/workflows/pr.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,28 @@ jobs:
2626
run: go vet ./...
2727
- name: Run tests
2828
run: go test -v ./...
29+
30+
image:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
- name: Setup Docker buildx
36+
uses: docker/[email protected]
37+
- name: Extract Docker metadata
38+
id: meta
39+
uses: docker/[email protected]
40+
with:
41+
images: |
42+
ghcr.io/flexstack/new-dockerfile
43+
- name: Build and push Docker image
44+
id: build-and-push
45+
uses: docker/[email protected]
46+
with:
47+
context: .
48+
push: false
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
platforms: linux/amd64,linux/arm64
52+
cache-from: type=gha
53+
cache-to: type=gha,mode=max

.github/workflows/release.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@ name: Release
22

33
on:
44
push:
5+
tags:
6+
- "*"
7+
branches:
8+
- main
59

610
permissions:
711
contents: write
812

913
jobs:
1014
release:
11-
if: startsWith(github.ref, 'refs/tags/')
1215
runs-on: ubuntu-latest
1316
steps:
1417
- name: Checkout
@@ -25,3 +28,34 @@ jobs:
2528
args: release --clean
2629
env:
2730
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
image:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
- name: Setup Docker buildx
38+
uses: docker/[email protected]
39+
- name: Log into registry
40+
uses: docker/[email protected]
41+
with:
42+
registry: ghcr.io
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
- name: Extract Docker metadata
46+
id: meta
47+
uses: docker/[email protected]
48+
with:
49+
images: |
50+
ghcr.io/flexstack/new-dockerfile
51+
- name: Build and push Docker image
52+
id: build-and-push
53+
uses: docker/[email protected]
54+
with:
55+
context: .
56+
push: true
57+
tags: ${{ steps.meta.outputs.tags }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
platforms: linux/amd64,linux/arm64
60+
cache-from: type=gha
61+
cache-to: type=gha,mode=max

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
node_modules
22
/dist/
3-
/Dockerfile
43
.idea/

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM docker.io/library/golang:1.21 AS builder
2+
3+
ARG GOPROXY=direct
4+
WORKDIR /app
5+
COPY . .
6+
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -o new-dockerfile cmd/new-dockerfile/main.go
7+
8+
FROM docker.io/library/alpine:3.19.1
9+
10+
WORKDIR /app
11+
COPY --from=builder /app/new-dockerfile /usr/local/bin
12+
13+
CMD [ "new-dockerfile" ]

0 commit comments

Comments
 (0)