Skip to content

Commit

Permalink
goreleaser: build docker images
Browse files Browse the repository at this point in the history
Add building docker images for AMD64 and ARM64 (v8).
To build locally run make dist.
It uses fixed tag `1.0.0-devel` across all snapshot builds.

```
 • docker images
    • building docker image                          image=saucelabs/forwarder:1.0.0-devel-amd64
    • building docker image                          image=saucelabs/forwarder:1.0.0-devel-arm64
    • took: 3s
  • storing release metadata
    • writing                                        file=dist/artifacts.json
    • writing                                        file=dist/metadata.json
```

Fixes #53
  • Loading branch information
mmatczuk committed Nov 2, 2022
1 parent 0cfdd3c commit 37afd7d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
23 changes: 23 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,26 @@ builds:

checksum:
name_template: "checksums"

dockers:
- image_templates:
- "{{ if .IsSnapshot }}saucelabs/{{.ProjectName}}:{{ .Tag }}-amd64{{ else }}saucelabs/{{.ProjectName}}:{{ .Version }}-amd64{{ end }}"
use: buildx
goos: linux
goarch: amd64
build_flag_templates:
- "--platform=linux/amd64"
- image_templates:
- "{{ if .IsSnapshot }}saucelabs/{{.ProjectName}}:{{ .Tag }}-arm64v8{{ else }}saucelabs/{{.ProjectName}}:{{ .Version }}-arm64v8{{ end }}"
use: buildx
goos: linux
goarch: arm64
goarm: 8
build_flag_templates:
- "--platform=linux/arm64/v8"

docker_manifests:
- name_template: "saucelabs/{{.ProjectName}}:{{ .Version }}"
image_templates:
- "saucelabs/{{.ProjectName}}:{{ .Tag }}-amd64"
- "saucelabs/{{.ProjectName}}:{{ .Tag }}-arm64v8"
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM ubuntu:22.10

RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates && \
apt-get clean && \
apt-get autoremove && \
rm -rf /var/lib/apt/lists/*

COPY forwarder /usr/bin/forwarder
ENTRYPOINT ["/usr/bin/forwarder"]
CMD ["proxy", "--api-address", ":10000"]
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
# Use of this source code is governed by a MIT
# license that can be found in the LICENSE file.

all: dev

export GOBIN := $(PWD)/bin
export PATH := $(GOBIN):$(PATH)

Expand All @@ -22,12 +20,7 @@ clean:
@rm -Rf bin dist *.coverprofile *.dev *.race *.test *.log
@go clean -cache -modcache -testcache ./... ||:

.PHONY: dev
dev: forwarder.race
@./forwarder.race run

forwarder.race: .check-go-version $(shell go list -f '{{range .GoFiles}}{{ $$.Dir }}/{{ . }} {{end}}' ./...)
@go build -o ./forwarder.race -race ./cmd/forwarder
### Testing

.PHONY: .check-go-version
.check-go-version:
Expand Down Expand Up @@ -57,6 +50,12 @@ integration-test:
coverage:
@go tool cover -func=coverage.out

### Release

.PHONY: dist
dist:
@GORELEASER_CURRENT_TAG=1.0.0-devel goreleaser --snapshot --rm-dist

.PHONY: doc
doc:
@echo "Open http://localhost:6060/pkg/github.com/saucelabs/forwarder/ in your browser\n"
Expand Down

0 comments on commit 37afd7d

Please sign in to comment.