Skip to content

Commit 0782072

Browse files
committed
Releasing docker image for arm64
Signed-off-by: odidev <[email protected]>
1 parent f6d7a75 commit 0782072

File tree

4 files changed

+54
-20
lines changed

4 files changed

+54
-20
lines changed

.github/workflows/tag.yml

+35
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ jobs:
1717
go-version: 1.15
1818
- name: Unshallow
1919
run: git fetch --prune --unshallow
20+
- name: Prepare
21+
id: prepare
22+
run: |
23+
TAG=${GITHUB_REF#refs/tags/}
24+
MAJOR=${TAG%.*}
25+
echo ::set-output name=tag_name::${TAG}
26+
echo ::set-output name=major_tag::${MAJOR}
27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v1
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v1
2031
- name: Login do docker.io
2132
run: docker login -u golangci -p ${{ secrets.GOLANGCI_LINT_DOCKER_TOKEN }}
2233
- name: Create release
@@ -26,3 +37,27 @@ jobs:
2637
args: release --rm-dist
2738
env:
2839
GITHUB_TOKEN: ${{ secrets.GOLANGCI_LINT_TOKEN }}
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
23

34
# don't place it into $GOPATH/bin because Drone mounts $GOPATH as volume
4-
COPY golangci-lint /usr/bin/
5+
RUN git clone https://github.com/golangci/golangci-lint
6+
WORKDIR golangci-lint
7+
RUN go build -o /usr/bin/golangci-lint ./cmd/golangci-lint/main.go
8+
9+
# stage 2
10+
FROM golang:1.15
11+
COPY --from=builder /usr/bin/golangci-lint /usr/bin/
512
CMD ["golangci-lint"]

build/Dockerfile.alpine

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
FROM golang:1.15-alpine
1+
# stage 1 building the code
2+
FROM golang:1.15-alpine as builder
23

34
# gcc is required to support cgo;
45
# git and mercurial are needed most times for go get`, etc.
56
# See https://github.com/docker-library/golang/issues/80
67
RUN apk --no-cache add gcc musl-dev git mercurial
78

89
# don't place it into $GOPATH/bin because Drone mounts $GOPATH as volume
9-
COPY golangci-lint /usr/bin/
10+
RUN git clone https://github.com/golangci/golangci-lint
11+
WORKDIR golangci-lint
12+
RUN CGO_ENABLED=0 go build -o /usr/bin/golangci-lint ./cmd/golangci-lint/main.go
13+
14+
# stage 2
15+
FROM golang:1.15-alpine
16+
RUN apk --no-cache add gcc musl-dev git mercurial
17+
COPY --from=builder /usr/bin/golangci-lint /usr/bin/
1018
CMD ["golangci-lint"]

0 commit comments

Comments
 (0)