diff --git a/Makefile.d/docker.mk b/Makefile.d/docker.mk index b6300732233..ff9b0e55c67 100644 --- a/Makefile.d/docker.mk +++ b/Makefile.d/docker.mk @@ -36,6 +36,26 @@ docker/name/org/alter: docker/platforms: @echo "linux/amd64,linux/arm64" +.PHONY: docker/build/image +## Generalized docker build function +docker/build/image: + DOCKER_BUILDKIT=1 $(DOCKER) buildx build \ + $(DOCKER_OPTS) \ + --cache-to type=registry,ref=$(ORG)/$(IMAGE):$(TAG)-buildcache,mode=max \ + --cache-from type=registry,ref=$(ORG)/$(IMAGE):$(TAG)-buildcache \ + --build-arg BUILDKIT_INLINE_CACHE=1 \ + --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ + --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \ + --build-arg MAINTAINER=$(MAINTAINER) \ + $(EXTRA_ARGS) \ + -t $(ORG)/$(IMAGE):$(TAG) \ + --push \ + -f $(DOCKERFILE) . + # --build-arg BUILDKIT_MULTI_PLATFORM=1 \ + # --platform $(DOCKER_BUILDER_PLATFORM) \ + + .PHONY: docker/name/agent-ngt docker/name/agent-ngt: @echo "$(ORG)/$(AGENT_IMAGE)" @@ -43,14 +63,10 @@ docker/name/agent-ngt: .PHONY: docker/build/agent-ngt ## build agent-ngt image docker/build/agent-ngt: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/agent/core/ngt/Dockerfile \ - -t $(ORG)/$(AGENT_IMAGE):$(TAG) . \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ - --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \ - --build-arg MAINTAINER=$(MAINTAINER) + @make DOCKERFILE="$(ROOTDIR)/dockers/agent/core/ngt/Dockerfile" \ + IMAGE=$(AGENT_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/agent-sidecar docker/name/agent-sidecar: @@ -59,14 +75,10 @@ docker/name/agent-sidecar: .PHONY: docker/build/agent-sidecar ## build agent-sidecar image docker/build/agent-sidecar: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/agent/sidecar/Dockerfile \ - -t $(ORG)/$(AGENT_SIDECAR_IMAGE):$(TAG) . \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ - --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \ - --build-arg MAINTAINER=$(MAINTAINER) + @make DOCKERFILE="$(ROOTDIR)/dockers/agent/sidecar/Dockerfile" \ + IMAGE=$(AGENT_SIDECAR_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/discoverer-k8s docker/name/discoverer-k8s: @@ -75,14 +87,10 @@ docker/name/discoverer-k8s: .PHONY: docker/build/discoverer-k8s ## build discoverer-k8s image docker/build/discoverer-k8s: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/discoverer/k8s/Dockerfile \ - -t $(ORG)/$(DISCOVERER_IMAGE):$(TAG) . \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ - --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \ - --build-arg MAINTAINER=$(MAINTAINER) + @make DOCKERFILE="$(ROOTDIR)/dockers/discoverer/k8s/Dockerfile" \ + IMAGE=$(DISCOVERER_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/gateway-lb docker/name/gateway-lb: @@ -91,13 +99,10 @@ docker/name/gateway-lb: .PHONY: docker/build/gateway-lb ## build gateway-lb image docker/build/gateway-lb: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/gateway/lb/Dockerfile \ - -t $(ORG)/$(LB_GATEWAY_IMAGE):$(TAG) . \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ - --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) + @make DOCKERFILE="$(ROOTDIR)/dockers/gateway/lb/Dockerfile" \ + IMAGE=$(LB_GATEWAY_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/gateway-filter docker/name/gateway-filter: @@ -106,13 +111,10 @@ docker/name/gateway-filter: .PHONY: docker/build/gateway-filter ## build gateway-filter image docker/build/gateway-filter: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/gateway/filter/Dockerfile \ - -t $(ORG)/$(FILTER_GATEWAY_IMAGE):$(TAG) . \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ - --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) + @make DOCKERFILE="$(ROOTDIR)/dockers/gateway/filter/Dockerfile" \ + IMAGE=$(FILTER_GATEWAY_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/manager-index docker/name/manager-index: @@ -121,14 +123,10 @@ docker/name/manager-index: .PHONY: docker/build/manager-index ## build manager-index image docker/build/manager-index: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/manager/index/Dockerfile \ - -t $(ORG)/$(MANAGER_INDEX_IMAGE):$(TAG) . \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ - --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \ - --build-arg MAINTAINER=$(MAINTAINER) + @make DOCKERFILE="$(ROOTDIR)/dockers/manager/index/Dockerfile" \ + IMAGE=$(MANAGER_INDEX_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/ci-container docker/name/ci-container: @@ -137,12 +135,9 @@ docker/name/ci-container: .PHONY: docker/build/ci-container ## build ci-container image docker/build/ci-container: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/ci/base/Dockerfile \ - -t $(ORG)/$(CI_CONTAINER_IMAGE):$(TAG) . \ - --build-arg MAINTAINER=$(MAINTAINER) \ - --build-arg GO_VERSION=$(GO_VERSION) + @make DOCKERFILE="$(ROOTDIR)/dockers/ci/base/Dockerfile" \ + IMAGE=$(CI_CONTAINER_IMAGE) \ + TAG=$(TAG) docker/build/image .PHONY: docker/name/dev-container docker/name/dev-container: @@ -151,11 +146,10 @@ docker/name/dev-container: .PHONY: docker/build/dev-container ## build dev-container image docker/build/dev-container: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/dev/Dockerfile \ - -t $(ORG)/$(DEV_CONTAINER_IMAGE):$(TAG) . \ - --build-arg MAINTAINER=$(MAINTAINER) + @make DOCKERFILE="$(ROOTDIR)/dockers/dev/Dockerfile" \ + IMAGE=$(DEV_CONTAINER_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/operator/helm docker/name/operator/helm: @@ -164,16 +158,11 @@ docker/name/operator/helm: .PHONY: docker/build/operator/helm ## build helm-operator image docker/build/operator/helm: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/operator/helm/Dockerfile \ - -t $(ORG)/$(HELM_OPERATOR_IMAGE):$(TAG) . \ - --build-arg GO_VERSION=$(GO_VERSION) \ - --build-arg DISTROLESS_IMAGE=$(DISTROLESS_IMAGE) \ - --build-arg DISTROLESS_IMAGE_TAG=$(DISTROLESS_IMAGE_TAG) \ - --build-arg MAINTAINER=$(MAINTAINER) \ - --build-arg OPERATOR_SDK_VERSION=$(OPERATOR_SDK_VERSION) \ - --build-arg UPX_OPTIONS=$(UPX_OPTIONS) + @make DOCKERFILE="$(ROOTDIR)/dockers/operator/helm/Dockerfile" \ + IMAGE=$(HELM_OPERATOR_IMAGE) \ + TAG=$(TAG) \ + EXTRA_ARGS="--build-arg OPERATOR_SDK_VERSION=$(OPERATOR_SDK_VERSION) --build-arg UPX_OPTIONS=$(UPX_OPTIONS)" \ + docker/build/image .PHONY: docker/name/loadtest docker/name/loadtest: @@ -182,12 +171,10 @@ docker/name/loadtest: .PHONY: docker/build/loadtest ## build loadtest image docker/build/loadtest: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/tools/cli/loadtest/Dockerfile \ - -t $(ORG)/$(LOADTEST_IMAGE):$(TAG) . \ - --build-arg MAINTAINER=$(MAINTAINER) \ - --build-arg GO_VERSION=$(GO_VERSION) + @make DOCKERFILE="$(ROOTDIR)/dockers/tools/cli/loadtest/Dockerfile" \ + IMAGE=$(LOADTEST_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/index-correction docker/name/index-correction: @@ -196,12 +183,10 @@ docker/name/index-correction: .PHONY: docker/build/index-correction ## build index-correction image docker/build/index-correction: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/index/job/correction/Dockerfile \ - -t $(ORG)/$(INDEX_CORRECTION_IMAGE):$(TAG) . \ - --build-arg MAINTAINER=$(MAINTAINER) \ - --build-arg GO_VERSION=$(GO_VERSION) + @make DOCKERFILE="$(ROOTDIR)/dockers/index/job/correction/Dockerfile" \ + IMAGE=$(INDEX_CORRECTION_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/index-creation docker/name/index-creation: @@ -210,12 +195,10 @@ docker/name/index-creation: .PHONY: docker/build/index-creation ## build index-creation image docker/build/index-creation: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/index/job/creation/Dockerfile \ - -t $(ORG)/$(INDEX_CREATION_IMAGE):$(TAG) . \ - --build-arg MAINTAINER=$(MAINTAINER) \ - --build-arg GO_VERSION=$(GO_VERSION) + @make DOCKERFILE="$(ROOTDIR)/dockers/index/job/creation/Dockerfile" \ + IMAGE=$(INDEX_CREATION_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/index-save docker/name/index-save: @@ -224,12 +207,10 @@ docker/name/index-save: .PHONY: docker/build/index-save ## build index-save image docker/build/index-save: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/index/job/save/Dockerfile \ - -t $(ORG)/$(INDEX_SAVE_IMAGE):$(TAG) . \ - --build-arg MAINTAINER=$(MAINTAINER) \ - --build-arg GO_VERSION=$(GO_VERSION) + @make DOCKERFILE="$(ROOTDIR)/dockers/index/job/save/Dockerfile" \ + IMAGE=$(INDEX_SAVE_IMAGE) \ + TAG=$(TAG) \ + docker/build/image .PHONY: docker/name/readreplica-rotate docker/name/readreplica-rotate: @@ -238,9 +219,7 @@ docker/name/readreplica-rotate: .PHONY: docker/build/readreplica-rotate ## build readreplica-rotate image docker/build/readreplica-rotate: - $(DOCKER) build \ - $(DOCKER_OPTS) \ - -f dockers/index/job/readreplica/rotate/Dockerfile \ - -t $(ORG)/$(READREPLICA_ROTATE_IMAGE):$(TAG) . \ - --build-arg MAINTAINER=$(MAINTAINER) \ - --build-arg GO_VERSION=$(GO_VERSION) + @make DOCKERFILE="$(ROOTDIR)/dockers/index/job/readreplica/rotate/Dockerfile" \ + IMAGE=$(READREPLICA_ROTATE_IMAGE) \ + TAG=$(TAG) \ + docker/build/image diff --git a/dockers/agent/core/ngt/Dockerfile b/dockers/agent/core/ngt/Dockerfile index da664738b63..fdc17ac1e67 100644 --- a/dockers/agent/core/ngt/Dockerfile +++ b/dockers/agent/core/ngt/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -19,9 +20,9 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ENV GO111MODULE on ENV DEBIAN_FRONTEND noninteractive @@ -92,7 +93,7 @@ RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} RUN cp sample.yaml /tmp/config.yaml -FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +FROM --platform=${BUILDPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} LABEL maintainer="${MAINTAINER}" ENV APP_NAME ngt diff --git a/dockers/agent/sidecar/Dockerfile b/dockers/agent/sidecar/Dockerfile index 3effcb88d30..eb58afdc6af 100644 --- a/dockers/agent/sidecar/Dockerfile +++ b/dockers/agent/sidecar/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -19,9 +20,9 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ENV GO111MODULE on ENV GOPATH /go @@ -81,7 +82,7 @@ WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO} RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ && mv "cmd/${PKG}/${APP_NAME}" "/usr/bin/${APP_NAME}" -FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +FROM --platform=${BUILDPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} LABEL maintainer="${MAINTAINER}" ENV APP_NAME sidecar diff --git a/dockers/ci/base/Dockerfile b/dockers/ci/base/Dockerfile index 2e007c2ee42..fc555370af3 100644 --- a/dockers/ci/base/Dockerfile +++ b/dockers/ci/base/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -17,9 +18,9 @@ ARG GO_VERSION=latest ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder LABEL maintainer="${MAINTAINER}" ENV GO111MODULE on diff --git a/dockers/dev/Dockerfile b/dockers/dev/Dockerfile index 1253743ad73..5ef6ab2ed1e 100644 --- a/dockers/dev/Dockerfile +++ b/dockers/dev/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -17,7 +18,7 @@ ARG MAINTAINER="vdaas.org vald team " # skipcq: DOK-DL3026 -FROM mcr.microsoft.com/vscode/devcontainers/go:1 AS base +FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/vscode/devcontainers/go:1 AS base LABEL maintainer="${MAINTAINER}" # skipcq: DOK-DL3008 diff --git a/dockers/discoverer/k8s/Dockerfile b/dockers/discoverer/k8s/Dockerfile index 7a1a87181dd..0b4ca84a0c1 100644 --- a/dockers/discoverer/k8s/Dockerfile +++ b/dockers/discoverer/k8s/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -19,9 +20,9 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ENV GO111MODULE on ENV DEBIAN_FRONTEND noninteractive @@ -81,7 +82,7 @@ RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} RUN cp sample.yaml /tmp/config.yaml -FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +FROM --platform=${BUILDPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} LABEL maintainer="${MAINTAINER}" ENV APP_NAME discoverer diff --git a/dockers/gateway/filter/Dockerfile b/dockers/gateway/filter/Dockerfile index 24761645153..8608a6946b3 100644 --- a/dockers/gateway/filter/Dockerfile +++ b/dockers/gateway/filter/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -19,9 +20,9 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ENV GO111MODULE on ENV DEBIAN_FRONTEND noninteractive @@ -80,7 +81,7 @@ RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} RUN cp sample.yaml /tmp/config.yaml -FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +FROM --platform=${BUILDPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} LABEL maintainer="${MAINTAINER}" ENV APP_NAME filter diff --git a/dockers/gateway/lb/Dockerfile b/dockers/gateway/lb/Dockerfile index a64ed6e0bc7..955e5ceae52 100644 --- a/dockers/gateway/lb/Dockerfile +++ b/dockers/gateway/lb/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -19,9 +20,9 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ENV GO111MODULE on ENV DEBIAN_FRONTEND noninteractive @@ -80,7 +81,7 @@ RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} RUN cp sample.yaml /tmp/config.yaml -FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +FROM --platform=${BUILDPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} LABEL maintainer="${MAINTAINER}" ENV APP_NAME lb diff --git a/dockers/index/job/correction/Dockerfile b/dockers/index/job/correction/Dockerfile index 1938e2531f9..ca560145b13 100644 --- a/dockers/index/job/correction/Dockerfile +++ b/dockers/index/job/correction/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -19,9 +20,9 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ENV GO111MODULE on ENV DEBIAN_FRONTEND noninteractive @@ -80,7 +81,7 @@ RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} RUN cp sample.yaml /tmp/config.yaml -FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +FROM --platform=${BUILDPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} LABEL maintainer="${MAINTAINER}" ENV APP_NAME index-correction diff --git a/dockers/index/job/creation/Dockerfile b/dockers/index/job/creation/Dockerfile index f17fb867f9d..efdb86d23e3 100644 --- a/dockers/index/job/creation/Dockerfile +++ b/dockers/index/job/creation/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -19,9 +20,9 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ENV GO111MODULE on ENV DEBIAN_FRONTEND noninteractive @@ -80,7 +81,7 @@ RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} RUN cp sample.yaml /tmp/config.yaml -FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +FROM --platform=${BUILDPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} LABEL maintainer="${MAINTAINER}" ENV APP_NAME index-creation diff --git a/dockers/index/job/save/Dockerfile b/dockers/index/job/save/Dockerfile index 9e7361d93b6..f60c15a49eb 100644 --- a/dockers/index/job/save/Dockerfile +++ b/dockers/index/job/save/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -19,9 +20,9 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ENV GO111MODULE on ENV DEBIAN_FRONTEND noninteractive @@ -80,7 +81,7 @@ RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} RUN cp sample.yaml /tmp/config.yaml -FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +FROM --platform=${BUILDPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} LABEL maintainer="${MAINTAINER}" ENV APP_NAME index-save diff --git a/dockers/manager/index/Dockerfile b/dockers/manager/index/Dockerfile index a41a212b5d4..d07c4270fa3 100644 --- a/dockers/manager/index/Dockerfile +++ b/dockers/manager/index/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -19,9 +20,9 @@ ARG DISTROLESS_IMAGE=gcr.io/distroless/static ARG DISTROLESS_IMAGE_TAG=nonroot ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ENV GO111MODULE on ENV DEBIAN_FRONTEND noninteractive @@ -80,7 +81,7 @@ RUN make REPO=${ORG} NAME=${REPO} cmd/${PKG}/${APP_NAME} \ WORKDIR ${GOPATH}/src/github.com/${ORG}/${REPO}/cmd/${PKG} RUN cp sample.yaml /tmp/config.yaml -FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +FROM --platform=${BUILDPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} LABEL maintainer="${MAINTAINER}" ENV APP_NAME index diff --git a/dockers/operator/helm/Dockerfile b/dockers/operator/helm/Dockerfile index 04053a2894d..a400e3ad1b4 100644 --- a/dockers/operator/helm/Dockerfile +++ b/dockers/operator/helm/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -25,9 +26,9 @@ ARG VALD_HELM_OPERATOR_KIND="ValdHelmOperatorRelease" ARG MAINTAINER="vdaas.org vald team " # skipcq: DOK-DL3026 -FROM quay.io/operator-framework/helm-operator:${OPERATOR_SDK_VERSION} AS operator -FROM golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} quay.io/operator-framework/helm-operator:${OPERATOR_SDK_VERSION} AS operator +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ARG OPERATOR_SDK_VERSION ARG VERSION @@ -123,7 +124,7 @@ COPY --from=operator /usr/local/bin/${APP_NAME} /usr/bin/${APP_NAME} RUN upx ${UPX_OPTIONS} "/usr/bin/${APP_NAME}" -FROM ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} +FROM --platform=${BUILDPLATFORM} ${DISTROLESS_IMAGE}:${DISTROLESS_IMAGE_TAG} LABEL maintainer="${MAINTAINER}" ENV APP_NAME helm-operator diff --git a/dockers/tools/cli/loadtest/Dockerfile b/dockers/tools/cli/loadtest/Dockerfile index 92695a5ba5b..b3d0226bf8e 100644 --- a/dockers/tools/cli/loadtest/Dockerfile +++ b/dockers/tools/cli/loadtest/Dockerfile @@ -1,3 +1,4 @@ +# syntax = docker/dockerfile:latest # # Copyright (C) 2019-2023 vdaas.org vald team # @@ -17,9 +18,9 @@ ARG GO_VERSION=latest ARG MAINTAINER="vdaas.org vald team " -FROM golang:${GO_VERSION} AS golang +FROM --platform=${BUILDPLATFORM} golang:${GO_VERSION} AS golang -FROM ubuntu:devel AS builder +FROM --platform=${BUILDPLATFORM} ubuntu:devel AS builder ENV GO111MODULE on ENV DEBIAN_FRONTEND noninteractive @@ -107,9 +108,9 @@ RUN GO_VERSION="$(< GO_VERSION)" \ && upx -9 -o "/usr/bin/${APP_NAME}" "${APP_NAME}" # Start From Scratch For Running Environment -FROM ubuntu:devel +FROM --platform=${BUILDPLATFORM} ubuntu:devel # Start From Alpine For Debug Environment -# FROM alpine:latest +# FROM --platform=${BUILDPLATFORM} alpine:latest LABEL maintainer="${MAINTAINER}" ENV APP_NAME loadtest diff --git a/hack/license/gen/main.go b/hack/license/gen/main.go index 64616be708f..9ce87051809 100644 --- a/hack/license/gen/main.go +++ b/hack/license/gen/main.go @@ -49,6 +49,23 @@ var ( {{.Escape}} See the License for the specific language governing permissions and {{.Escape}} limitations under the License. {{.Escape}} +`)) + docker = template.Must(template.New("Apache License").Parse(`{{.Escape}} syntax = docker/dockerfile:latest +{{.Escape}} +{{.Escape}} Copyright (C) 2019-{{.Year}} {{.Maintainer}} +{{.Escape}} +{{.Escape}} Licensed under the Apache License, Version 2.0 (the "License"); +{{.Escape}} You may not use this file except in compliance with the License. +{{.Escape}} You may obtain a copy of the License at +{{.Escape}} +{{.Escape}} https://www.apache.org/licenses/LICENSE-2.0 +{{.Escape}} +{{.Escape}} Unless required by applicable law or agreed to in writing, software +{{.Escape}} distributed under the License is distributed on an "AS IS" BASIS, +{{.Escape}} WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +{{.Escape}} See the License for the specific language governing permissions and +{{.Escape}} limitations under the License. +{{.Escape}} `)) googleProtoApache = template.Must(template.New("Google Proto Apache License").Parse(`{{.Escape}} @@ -259,6 +276,10 @@ func readAndRewrite(path string) error { tmpl = googleProtoApache } d.Escape = slushEscape + default: + if fi.Name() == "Dockerfile" { + tmpl = docker + } } lf := true bf := false