diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 404cb6c5..c0b901b7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -31,13 +31,16 @@ jobs: strategy: fail-fast: false matrix: - platform: - - linux/amd64 - - linux/arm64 + arch: + - amd64 + - arm64 steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + - run: make cross - name: Docker meta id: meta uses: docker/metadata-action@v5 @@ -72,8 +75,10 @@ jobs: id: build uses: docker/build-push-action@v5 with: + build-args: + arch=${{ matrix.arch }} context: . - platforms: ${{ matrix.platform }} + platforms: linux/${{ matrix.arch }} labels: ${{ steps.meta.outputs.labels }} outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} cache-from: type=gha @@ -86,7 +91,7 @@ jobs: mkdir -p /tmp/digests digest="${{ steps.build.outputs.digest }}" touch "/tmp/digests/${digest#sha256:}" - echo "artifact_name=digests-${{ matrix.platform }}" | sed -e 's/\//-/g' >> "$GITHUB_OUTPUT" + echo "artifact_name=digests-linux/${{ matrix.arch }}" | sed -e 's/\//-/g' >> "$GITHUB_OUTPUT" - name: Upload digest if: github.event_name != 'pull_request' diff --git a/Dockerfile b/Dockerfile index 1ca70e05..c6acefbf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,13 @@ FROM golang:1.20.6 ARG JSONNET_VERSION=v0.19.1 ARG JB_VERSION=v0.5.1 -WORKDIR /app -RUN wget https://github.com/mitchellh/gox/archive/refs/tags/v1.0.1.tar.gz \ - && tar -xzf v1.0.1.tar.gz \ - && cd gox-1.0.1/ \ - && go build \ - && mv gox /usr/local/bin RUN CGO_ENABLED=0 go install github.com/google/go-jsonnet/cmd/jsonnet@${JSONNET_VERSION} && \ CGO_ENABLED=0 go install github.com/google/go-jsonnet/cmd/jsonnetfmt@${JSONNET_VERSION} && \ CGO_ENABLED=0 go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@${JB_VERSION} -COPY . . -RUN make install FROM alpine -COPY --from=0 /go/bin/grr /usr/local/bin/grr +ARG arch=amd64 +COPY /dist/grr-linux-${arch} /usr/local/bin/grr COPY --from=0 /go/bin/jsonnet /usr/local/bin/jsonnet COPY --from=0 /go/bin/jsonnetfmt /usr/local/bin/jsonnetfmt COPY --from=0 /go/bin/jb /usr/local/bin/jb diff --git a/Makefile b/Makefile index 5def0168..a7d901c2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: dev lint test integration static install uninstall cross build-test-image run-test-image-locally test-clean +.PHONY: dev lint test integration install uninstall cross build-test-image run-test-image-locally test-clean VERSION := $(shell git describe --tags --dirty --always) BIN_DIR := $(GOPATH)/bin GOX := $(BIN_DIR)/gox @@ -28,8 +28,6 @@ dev: go build -ldflags "-X main.Version=dev-${VERSION}" ./cmd/grr LDFLAGS := '-s -w -extldflags "-static" -X main.Version=${VERSION}' -static: - CGO_ENABLED=0 GOOS=linux go build -ldflags=${LDFLAGS} ./cmd/grr install: CGO_ENABLED=0 go install -ldflags=${LDFLAGS} ./cmd/grr @@ -45,5 +43,5 @@ cross: $(GOX) CGO_ENABLED=0 $(GOPATH)/bin/gox -output="dist/{{.Dir}}-{{.OS}}-{{.Arch}}" -ldflags=${LDFLAGS} -arch="amd64 arm64 arm" -os="linux" -osarch="darwin/amd64 darwin/arm64" ./cmd/grr # Docker container -container: static +container: cross docker build -t grafana/grizzly .