feat: add goreleaser docker image publish

This commit is contained in:
engigu
2024-01-27 22:11:27 +08:00
parent b81de54890
commit 86ffa87dcc
3 changed files with 71 additions and 25 deletions
+14 -11
View File
@@ -19,6 +19,8 @@ jobs:
env: env:
NODE_ENV: prod NODE_ENV: prod
CUSTOM_PROJ_NAME: Message-Nest
DOCKER_IMAGE_NAME: message-nest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@@ -26,22 +28,23 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- run: git fetch --force --tags - run: git fetch --force --tags
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Docker Login
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWD }}
- uses: actions/setup-go@v3 - uses: actions/setup-go@v3
with: with:
go-version: '>=1.20.2' go-version: '>=1.20.2'
cache: true cache: true
- name: Install npm dependencies - name: Git File Restore
run: npm i run: git checkout .
working-directory: web/
- name: Run npm build
run: export NODE_ENV=prod && npm run build
working-directory: web/
- name: Check build static
run: ls dist/ -la
working-directory: web/
# More assembly might be required: Docker logins, GPG, etc. It all depends # More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs. # on your needs.
+51 -8
View File
@@ -6,20 +6,63 @@ before:
- go mod tidy - go mod tidy
# you may remove this if you don't need go generate # you may remove this if you don't need go generate
- go generate ./... - go generate ./...
builds: builds:
- env: - env: [ CGO_ENABLED=0 ]
- CGO_ENABLED=0
goos: goos:
- linux - linux
- windows - windows
- darwin - darwin
goarch:
- amd64
- arm64
id: "{{ .Env.CUSTOM_PROJ_NAME }}"
binary: "{{ .Env.CUSTOM_PROJ_NAME }}"
dockers:
- image_templates: [ "docker.io/engigu/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Version }}-amd64" ]
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/engigu/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/engigu/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
- image_templates: [ "docker.io/engigu/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Version }}-arm64v8" ]
goarch: arm64
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/engigu/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/engigu/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
docker_manifests:
- name_template: docker.io/engigu/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Version }}
image_templates:
- docker.io/engigu/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Version }}-amd64
- docker.io/engigu/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Version }}-arm64v8
- name_template: docker.io/engigu/{{ .Env.DOCKER_IMAGE_NAME }}:latest
image_templates:
- docker.io/engigu/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Version }}-amd64
- docker.io/engigu/{{ .Env.DOCKER_IMAGE_NAME }}:{{ .Version }}-arm64v8
archives: archives:
- format: tar.gz - format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname. # this name template makes the OS and Arch compatible with the results of uname.
# {{ .ProjectName }}_ # {{ .ProjectName }}_
name_template: >- name_template: >-
Message-Nest_ {{ .Env.CUSTOM_PROJ_NAME }}_
{{- title .Os }}_ {{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64 {{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386 {{- else if eq .Arch "386" }}i386
@@ -27,12 +70,12 @@ archives:
{{- if .Arm }}v{{ .Arm }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives # use zip for windows archives
format_overrides: format_overrides:
- goos: windows - goos: windows
format: zip format: zip
files: files:
- LICENSE - LICENSE
- README.md - README.md
- conf/* - conf/*
checksum: checksum:
name_template: 'checksums.txt' name_template: 'checksums.txt'
+6 -6
View File
@@ -1,9 +1,9 @@
FROM golang:latest FROM ubuntu:latest
COPY ./ /app/
ENV GOPROXY https://goproxy.cn,direct
WORKDIR /app WORKDIR /app
COPY . /app
RUN go build .
EXPOSE 8000 EXPOSE 8000
ENTRYPOINT ["./Message-Nest"]
CMD ["/app/Message-Nest"]