Skip to content

Commit

Permalink
optimize docker build and fix version
Browse files Browse the repository at this point in the history
  • Loading branch information
dmachard committed Oct 15, 2023
1 parent fc12b26 commit 7e80cd6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
go-version: ${{ matrix.go-version }}

- name: build binary
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o go-dnscollector *.go
run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o go-dnscollector *.go

go-freebsd:
runs-on: ubuntu-latest
Expand All @@ -46,7 +46,7 @@ jobs:
go-version: ${{ matrix.go-version }}

- name: build binary
run: CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o go-dnscollector *.go
run: CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags="-s -w" -o go-dnscollector *.go

# for macos and window, limit the build to the latest version
go-macos:
Expand All @@ -63,7 +63,7 @@ jobs:
go-version: ${{ matrix.go-version }}

- name: build binary
run: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o go-dnscollector *.go
run: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o go-dnscollector *.go

go-win:
runs-on: windows-latest
Expand All @@ -81,7 +81,7 @@ jobs:
- name: build binary
run: |
set CGO_ENABLED=0
go build -o go-dnscollector.exe .
go build -ldflags="-s -w" -o go-dnscollector.exe .
docker:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG VERSION
WORKDIR /build
COPY . .
RUN apk add git
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-X 'main.Version=$VERSION'"
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X 'github.com/prometheus/common/version.Version=$VERSION'"


FROM alpine:3.18.4
Expand Down

0 comments on commit 7e80cd6

Please sign in to comment.