Skip to content

Commit

Permalink
feat: support to publish new-dockerfile as image (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: rick <[email protected]>
  • Loading branch information
LinuxSuRen and LinuxSuRen authored May 20, 2024
1 parent 7488c69 commit bc81514
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,28 @@ jobs:
run: go vet ./...
- name: Run tests
run: go test -v ./...

image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/[email protected]
- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
images: |
ghcr.io/flexstack/new-dockerfile
- name: Build and push Docker image
id: build-and-push
uses: docker/[email protected]
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
36 changes: 35 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ name: Release

on:
push:
tags:
- "*"
branches:
- main

permissions:
contents: write

jobs:
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -25,3 +28,34 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/[email protected]
- name: Log into registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
images: |
ghcr.io/flexstack/new-dockerfile
- name: Build and push Docker image
id: build-and-push
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
/dist/
/Dockerfile
.idea/
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM docker.io/library/golang:1.21 AS builder

ARG GOPROXY=direct
WORKDIR /app
COPY . .
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -o new-dockerfile cmd/new-dockerfile/main.go

FROM docker.io/library/alpine:3.19.1

WORKDIR /app
COPY --from=builder /app/new-dockerfile /usr/local/bin

CMD [ "new-dockerfile" ]

0 comments on commit bc81514

Please sign in to comment.