2020-06-10 15:07:25 +02:00
|
|
|
# syntax = docker/dockerfile:experimental
|
2020-06-10 15:16:11 +02:00
|
|
|
ARG GO_VERSION=1.14.4-alpine
|
|
|
|
ARG ALPINE_PKG_DOCKER_VERSION=19.03.11-r0
|
|
|
|
ARG GOLANGCI_LINT_VERSION=v1.27.0-alpine
|
2020-06-10 15:07:25 +02:00
|
|
|
|
2020-06-10 15:16:11 +02:00
|
|
|
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS base
|
|
|
|
WORKDIR /ecs-plugin
|
2020-06-10 15:07:25 +02:00
|
|
|
ENV GO111MODULE=on
|
2020-06-10 15:16:11 +02:00
|
|
|
ARG ALPINE_PKG_DOCKER_VERSION
|
|
|
|
RUN apk add --no-cache \
|
|
|
|
docker=${ALPINE_PKG_DOCKER_VERSION} \
|
2020-06-25 08:14:54 +02:00
|
|
|
make \
|
|
|
|
build-base
|
2020-06-10 15:16:11 +02:00
|
|
|
COPY go.* .
|
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
|
|
go mod download
|
2020-06-10 15:07:25 +02:00
|
|
|
|
|
|
|
FROM base AS make-plugin
|
2020-06-10 15:16:11 +02:00
|
|
|
ARG TARGETOS
|
|
|
|
ARG TARGETARCH
|
2020-06-30 11:37:03 +02:00
|
|
|
ARG COMMIT
|
|
|
|
ARG TAG
|
|
|
|
COPY . .
|
2020-06-10 15:07:25 +02:00
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
2020-06-10 15:16:11 +02:00
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
|
|
|
GOOS=${TARGETOS} \
|
|
|
|
GOARCH=${TARGETARCH} \
|
2020-06-10 15:07:25 +02:00
|
|
|
make -f builder.Makefile build
|
|
|
|
|
|
|
|
FROM base AS make-cross
|
2020-06-30 11:37:03 +02:00
|
|
|
ARG COMMIT
|
|
|
|
ARG TAG
|
|
|
|
COPY . .
|
2020-06-10 15:07:25 +02:00
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
2020-06-10 15:16:11 +02:00
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
2020-06-10 15:07:25 +02:00
|
|
|
make -f builder.Makefile cross
|
|
|
|
|
|
|
|
FROM scratch AS build
|
2020-06-10 15:16:11 +02:00
|
|
|
COPY --from=make-plugin /ecs-plugin/dist/docker-ecs .
|
2020-06-10 15:07:25 +02:00
|
|
|
|
|
|
|
FROM scratch AS cross
|
|
|
|
COPY --from=make-cross /ecs-plugin/dist/* .
|
|
|
|
|
2020-06-10 15:16:11 +02:00
|
|
|
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
|