Skip to content

Commit

Permalink
optimize build size (#3)
Browse files Browse the repository at this point in the history
* Update Makefile

* Update Dockerfile

* Update release.yml

* Update release.yml
  • Loading branch information
fengjian authored Dec 15, 2022
1 parent dbb94b8 commit 9999bd3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
- name: Build
run: |
go build -o "$BINARY_NAME" cmd/main.go
go build -ldflags "-w -s" -o "$BINARY_NAME" cmd/main.go
- name: Release Notes
run:
git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s%n * %an <%ae>' --no-merges >> ".github/RELEASE-TEMPLATE.md"
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKDIR /workspace
COPY . .

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o goose cmd/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w -s" -o goose cmd/main.go

FROM alpine:3.16.0

Expand All @@ -17,4 +17,4 @@ RUN apk add iptables
COPY --from=builder /workspace/goose .


ENTRYPOINT ["/goose"]
ENTRYPOINT ["/goose"]
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ REPO ?= goose
all: linux windows

linux:
GOOS=linux GOARCH=amd64 go build -o bin/goose cmd/main.go
GOOS=linux GOARCH=amd64 go build -ldflags "-w -s" -o bin/goose cmd/main.go

windows:
GOOS=windows GOARCH=amd64 go build -o bin/goose.exe cmd/main.go
GOOS=windows GOARCH=amd64 go build -ldflags "-w -s" -o bin/goose.exe cmd/main.go

arm32:
GOOS=linux GOARCH=arm32 go build -o bin/goose cmd/main.go
GOOS=linux GOARCH=arm32 go build -ldflags "-w -s" -o bin/goose cmd/main.go

docker-build:
docker build -t $(REGISTRY)/$(REPO):$(VERSION) .
Expand Down

0 comments on commit 9999bd3

Please sign in to comment.