forked from docker-archive/ecs-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
57 lines (49 loc) · 1.54 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# syntax = docker/dockerfile:experimental
ARG GO_VERSION=1.14.4-alpine
ARG ALPINE_PKG_DOCKER_VERSION=19.03.12-r0
ARG GOLANGCI_LINT_VERSION=v1.27.0-alpine
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS base
WORKDIR /ecs-plugin
ENV GO111MODULE=on
ARG ALPINE_PKG_DOCKER_VERSION
RUN apk add --no-cache \
docker=${ALPINE_PKG_DOCKER_VERSION} \
make \
build-base
COPY go.* .
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
FROM base AS make-plugin
ARG TARGETOS
ARG TARGETARCH
ARG COMMIT
ARG TAG
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
make -f builder.Makefile build
FROM base AS make-cross
ARG COMMIT
ARG TAG
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
make -f builder.Makefile cross
FROM scratch AS build
COPY --from=make-plugin /ecs-plugin/dist/docker-ecs .
FROM scratch AS cross
COPY --from=make-cross /ecs-plugin/dist/* .
FROM make-plugin AS test
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
make -f builder.Makefile test
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION} AS lint-base
FROM base AS lint
COPY --from=lint-base /usr/bin/golangci-lint /usr/bin/golangci-lint
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/golangci-lint \
make -f builder.Makefile lint