Skip to content

Commit 3368a55

Browse files
authored
Releasing docker image for arm64 (#1383)
1 parent 3e6b01e commit 3368a55

File tree

4 files changed

+53
-21
lines changed

4 files changed

+53
-21
lines changed

.github/workflows/tag.yml

+35
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,38 @@ jobs:
2626
args: release --rm-dist
2727
env:
2828
GITHUB_TOKEN: ${{ secrets.GOLANGCI_LINT_TOKEN }}
29+
- name: Prepare
30+
id: prepare
31+
run: |
32+
TAG=${GITHUB_REF#refs/tags/}
33+
MAJOR=${TAG%.*}
34+
echo ::set-output name=tag_name::${TAG}
35+
echo ::set-output name=major_tag::${MAJOR}
36+
- name: Set up QEMU
37+
uses: docker/setup-qemu-action@v1
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v1
40+
- name: build and publish main image
41+
id: docker_build
42+
uses: docker/build-push-action@v2
43+
with:
44+
context: .
45+
file: build/Dockerfile
46+
platforms: linux/amd64,linux/arm64
47+
push: true
48+
tags: |
49+
golangci/golangci-lint:${{ steps.prepare.outputs.tag_name }}
50+
golangci/golangci-lint:${{ steps.prepare.outputs.major_tag }}
51+
golangci/golangci-lint:latest
52+
- name: build and publish alpine image
53+
id: docker_build_alpine
54+
uses: docker/build-push-action@v2
55+
with:
56+
context: .
57+
file: build/Dockerfile.alpine
58+
platforms: linux/amd64,linux/arm64
59+
push: true
60+
tags: |
61+
golangci/golangci-lint:${{ steps.prepare.outputs.tag_name }}-alpine
62+
golangci/golangci-lint:${{ steps.prepare.outputs.major_tag }}-alpine
63+
golangci/golangci-lint:latest-alpine

.goreleaser.yml

-16
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,6 @@ changelog:
6363
- Merge pull request
6464
- Merge branch
6565

66-
dockers:
67-
- dockerfile: build/Dockerfile
68-
binaries:
69-
- golangci-lint
70-
image_templates:
71-
- "golangci/golangci-lint:latest"
72-
- "golangci/golangci-lint:{{ .Tag }}"
73-
- "golangci/golangci-lint:v{{ .Major }}.{{ .Minor }}"
74-
- dockerfile: build/Dockerfile.alpine
75-
binaries:
76-
- golangci-lint
77-
image_templates:
78-
- "golangci/golangci-lint:latest-alpine"
79-
- "golangci/golangci-lint:{{ .Tag }}-alpine"
80-
- "golangci/golangci-lint:v{{ .Major }}.{{ .Minor }}-alpine"
81-
8266
brews:
8367
- tap:
8468
owner: golangci

build/Dockerfile

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
FROM golang:1.15
1+
# stage 1 building the code
2+
FROM golang:1.15 as builder
3+
4+
COPY / /golangci
5+
WORKDIR /golangci
6+
RUN go build -o golangci-lint ./cmd/golangci-lint/main.go
27

8+
# stage 2
9+
FROM golang:1.15
310
# don't place it into $GOPATH/bin because Drone mounts $GOPATH as volume
4-
COPY golangci-lint /usr/bin/
11+
COPY --from=builder /golangci/golangci-lint /usr/bin/
512
CMD ["golangci-lint"]

build/Dockerfile.alpine

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
FROM golang:1.15-alpine
1+
# stage 1 building the code
2+
FROM golang:1.15-alpine as builder
3+
4+
COPY / /golangci
5+
WORKDIR /golangci
6+
RUN CGO_ENABLED=0 go build -o golangci-lint ./cmd/golangci-lint/main.go
27

8+
# stage 2
9+
FROM golang:1.15-alpine
310
# gcc is required to support cgo;
411
# git and mercurial are needed most times for go get`, etc.
512
# See https://github.com/docker-library/golang/issues/80
613
RUN apk --no-cache add gcc musl-dev git mercurial
7-
814
# don't place it into $GOPATH/bin because Drone mounts $GOPATH as volume
9-
COPY golangci-lint /usr/bin/
15+
COPY --from=builder /golangci/golangci-lint /usr/bin/
1016
CMD ["golangci-lint"]

0 commit comments

Comments
 (0)