2021-04-13 16:19:20 +03:00
|
|
|
# syntax=docker/dockerfile:1.2
|
2020-08-17 17:20:02 +03:00
|
|
|
|
|
|
|
|
2020-09-22 13:13:00 +03:00
|
|
|
# Copyright 2020 Docker Compose CLI authors
|
2020-06-18 17:13:24 +03:00
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2020-09-22 13:13:00 +03:00
|
|
|
|
2021-02-17 19:51:14 +03:00
|
|
|
ARG GO_VERSION=1.16-alpine
|
2021-04-13 16:19:20 +03:00
|
|
|
ARG GOLANGCI_LINT_VERSION=v1.39.0-alpine
|
2020-10-27 16:09:28 +03:00
|
|
|
ARG PROTOC_GEN_GO_VERSION=v1.4.3
|
2020-04-22 11:04:11 +03:00
|
|
|
|
2020-05-29 12:30:12 +03:00
|
|
|
FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS base
|
2020-08-21 18:24:53 +03:00
|
|
|
WORKDIR /compose-cli
|
2021-04-13 16:19:20 +03:00
|
|
|
RUN apk add --no-cache -vv \
|
2020-08-18 17:10:34 +03:00
|
|
|
git \
|
2020-05-29 12:30:12 +03:00
|
|
|
docker \
|
|
|
|
make \
|
2020-06-05 17:28:18 +03:00
|
|
|
protoc \
|
|
|
|
protobuf-dev
|
2020-05-29 12:30:12 +03:00
|
|
|
COPY go.* .
|
2020-09-23 18:13:27 +03:00
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
|
|
go mod download
|
2020-05-05 00:49:40 +03:00
|
|
|
|
2020-05-29 12:30:12 +03:00
|
|
|
FROM base AS make-protos
|
2020-10-27 16:09:28 +03:00
|
|
|
ARG PROTOC_GEN_GO_VERSION
|
|
|
|
RUN go get github.com/golang/protobuf/protoc-gen-go@${PROTOC_GEN_GO_VERSION}
|
2020-05-29 12:30:12 +03:00
|
|
|
COPY . .
|
2020-05-01 16:27:27 +03:00
|
|
|
RUN make -f builder.Makefile protos
|
2020-04-22 11:04:11 +03:00
|
|
|
|
2020-05-29 12:30:12 +03:00
|
|
|
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION} AS lint-base
|
2020-05-22 14:04:27 +03:00
|
|
|
|
|
|
|
FROM base AS lint
|
|
|
|
ENV CGO_ENABLED=0
|
2020-05-29 12:30:12 +03:00
|
|
|
COPY --from=lint-base /usr/bin/golangci-lint /usr/bin/golangci-lint
|
2020-11-18 19:18:15 +03:00
|
|
|
ARG BUILD_TAGS
|
2020-07-07 16:48:09 +03:00
|
|
|
ARG GIT_TAG
|
2020-05-29 12:30:12 +03:00
|
|
|
RUN --mount=target=. \
|
2020-09-23 18:13:27 +03:00
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
2020-05-29 12:30:12 +03:00
|
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
--mount=type=cache,target=/root/.cache/golangci-lint \
|
2020-11-18 19:18:15 +03:00
|
|
|
BUILD_TAGS=${BUILD_TAGS} \
|
2020-07-07 16:48:09 +03:00
|
|
|
GIT_TAG=${GIT_TAG} \
|
2020-05-22 14:04:27 +03:00
|
|
|
make -f builder.Makefile lint
|
|
|
|
|
2020-08-18 17:10:34 +03:00
|
|
|
FROM base AS import-restrictions-base
|
|
|
|
RUN go get github.com/docker/import-restrictions
|
|
|
|
|
|
|
|
FROM import-restrictions-base AS import-restrictions
|
|
|
|
RUN --mount=target=. \
|
2020-09-23 18:13:27 +03:00
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
2020-08-18 17:10:34 +03:00
|
|
|
make -f builder.Makefile import-restrictions
|
|
|
|
|
2020-05-14 14:35:55 +03:00
|
|
|
FROM base AS make-cli
|
2020-05-29 12:30:12 +03:00
|
|
|
ENV CGO_ENABLED=0
|
|
|
|
ARG TARGETOS
|
|
|
|
ARG TARGETARCH
|
2020-06-15 18:41:59 +03:00
|
|
|
ARG BUILD_TAGS
|
2020-07-07 16:48:09 +03:00
|
|
|
ARG GIT_TAG
|
2020-05-29 12:30:12 +03:00
|
|
|
RUN --mount=target=. \
|
2020-09-23 18:13:27 +03:00
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
2020-05-29 12:30:12 +03:00
|
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
GOOS=${TARGETOS} \
|
|
|
|
GOARCH=${TARGETARCH} \
|
2020-06-15 18:41:59 +03:00
|
|
|
BUILD_TAGS=${BUILD_TAGS} \
|
2020-07-07 16:48:09 +03:00
|
|
|
GIT_TAG=${GIT_TAG} \
|
2021-03-22 16:12:57 +03:00
|
|
|
make BINARY=/out/docker COMPOSE_BINARY=/out/docker-compose -f builder.Makefile cli
|
2020-04-22 11:04:11 +03:00
|
|
|
|
2020-05-14 14:35:55 +03:00
|
|
|
FROM base AS make-cross
|
2020-06-15 18:41:59 +03:00
|
|
|
ARG BUILD_TAGS
|
2020-07-07 16:48:09 +03:00
|
|
|
ARG GIT_TAG
|
2020-05-29 12:30:12 +03:00
|
|
|
RUN --mount=target=. \
|
2020-09-23 18:13:27 +03:00
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
2020-05-29 12:30:12 +03:00
|
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
2020-06-15 18:41:59 +03:00
|
|
|
BUILD_TAGS=${BUILD_TAGS} \
|
2020-07-07 16:48:09 +03:00
|
|
|
GIT_TAG=${GIT_TAG} \
|
2021-03-22 16:12:57 +03:00
|
|
|
make BINARY=/out/docker COMPOSE_BINARY=/out/docker-compose -f builder.Makefile cross
|
2020-04-22 11:04:11 +03:00
|
|
|
|
|
|
|
FROM scratch AS protos
|
2021-01-19 18:48:54 +03:00
|
|
|
COPY --from=make-protos /compose-cli/cli/server/protos .
|
2020-04-22 11:04:11 +03:00
|
|
|
|
2020-05-01 16:27:27 +03:00
|
|
|
FROM scratch AS cli
|
2020-05-29 12:30:12 +03:00
|
|
|
COPY --from=make-cli /out/* .
|
2020-05-01 16:27:27 +03:00
|
|
|
|
2020-05-04 11:32:30 +03:00
|
|
|
FROM scratch AS cross
|
2020-05-29 12:30:12 +03:00
|
|
|
COPY --from=make-cross /out/* .
|
2020-04-22 11:04:11 +03:00
|
|
|
|
2020-12-04 19:33:52 +03:00
|
|
|
FROM base AS test
|
2020-05-20 15:32:56 +03:00
|
|
|
ENV CGO_ENABLED=0
|
2020-07-07 16:48:09 +03:00
|
|
|
ARG BUILD_TAGS
|
|
|
|
ARG GIT_TAG
|
2020-05-29 12:30:12 +03:00
|
|
|
RUN --mount=target=. \
|
2020-09-23 18:13:27 +03:00
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
2020-05-29 12:30:12 +03:00
|
|
|
--mount=type=cache,target=/root/.cache/go-build \
|
2020-06-15 18:41:59 +03:00
|
|
|
BUILD_TAGS=${BUILD_TAGS} \
|
2020-07-07 16:48:09 +03:00
|
|
|
GIT_TAG=${GIT_TAG} \
|
2020-05-22 14:26:30 +03:00
|
|
|
make -f builder.Makefile test
|
2020-08-17 16:18:47 +03:00
|
|
|
|
2020-12-04 19:33:52 +03:00
|
|
|
FROM base AS check-license-headers
|
2020-08-21 18:24:53 +03:00
|
|
|
RUN go get -u github.com/kunalkushwaha/ltag
|
2020-08-17 16:18:47 +03:00
|
|
|
RUN --mount=target=. \
|
2020-08-17 17:20:02 +03:00
|
|
|
make -f builder.Makefile check-license-headers
|
|
|
|
|
2020-12-04 19:48:15 +03:00
|
|
|
FROM base AS make-go-mod-tidy
|
|
|
|
COPY . .
|
|
|
|
RUN --mount=type=cache,target=/go/pkg/mod \
|
|
|
|
go mod tidy
|
|
|
|
|
|
|
|
FROM scratch AS go-mod-tidy
|
|
|
|
COPY --from=make-go-mod-tidy /compose-cli/go.mod .
|
|
|
|
COPY --from=make-go-mod-tidy /compose-cli/go.sum .
|
|
|
|
|
2020-12-04 19:33:52 +03:00
|
|
|
FROM base AS check-go-mod
|
2020-08-18 12:53:17 +03:00
|
|
|
COPY . .
|
2020-09-23 18:13:40 +03:00
|
|
|
RUN make -f builder.Makefile check-go-mod
|