Skip to content

Commit

Permalink
Update workflows and Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
xwjdsh committed May 15, 2023
1 parent 139eddf commit 1b21d87
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 40 deletions.
23 changes: 3 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,17 @@ name: build

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
ci:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: 1.19

go-version: 1.20
- name: Build
run: go build

release-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Release test
- name: Test
run: go test ./...
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ jobs:
with:
go-version: 1.19

- name: "Docker login"
run: docker login ghcr.io -u docker -p ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
Expand Down
4 changes: 4 additions & 0 deletions .goreleaser.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM alpine:3.17
WORKDIR /app
COPY botastic .
ENTRYPOINT ["/app/botastic"]
17 changes: 6 additions & 11 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ builds:
goarch:
- amd64
env:
- CGO_ENABLED=0
- CGO_ENABLED=1
ldflags:
- -s -w -X main.version={{.Version}} -X main.commit={{.ShortCommit}}
dockers:
- id: botastic
goos: linux
goarch: amd64
dockerfile: Dockerfile
dockerfile: .goreleaser.Dockerfile
image_templates:
- "ghcr.io/pandodao/{{ .ProjectName }}/botastic:latest"
- "ghcr.io/pandodao/{{ .ProjectName }}/botastic:{{ .Major }}"
- "ghcr.io/pandodao/{{ .ProjectName }}/botastic:{{ .Major }}.{{ .Minor }}"
- "ghcr.io/pandodao/{{ .ProjectName }}/botastic:{{ .Major }}.{{ .Minor }}.{{ .Patch }}"
blobs:
- provider: s3
region: us-east-2
bucket: goreleaser-builds
folder: "botastic"
- "ghcr.io/pandodao/botastic:latest"
- "ghcr.io/pandodao/botastic:{{ .Major }}"
- "ghcr.io/pandodao/botastic:{{ .Major }}.{{ .Minor }}"
- "ghcr.io/pandodao/botastic:{{ .Major }}.{{ .Minor }}.{{ .Patch }}"
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
FROM alpine as build
RUN apk --no-cache add ca-certificates
FROM golang:1.20-alpine3.17 AS builder
WORKDIR /app
COPY . .
RUN apk add --no-cache git make build-base
RUN CGO_ENABLED=1 go build -trimpath -o botastic

FROM scratch
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY botastic /usr/bin/
ENTRYPOINT ["/usr/bin/botastic"]
FROM alpine:3.17
WORKDIR /app
COPY --from=builder /app/botastic .
RUN chmod +x /app/botastic
ENTRYPOINT ["/app/botastic"]

0 comments on commit 1b21d87

Please sign in to comment.