diff --git a/deploy/Dockerfile b/deploy/Dockerfile index 1fe6bc0974..93f63705c8 100644 --- a/deploy/Dockerfile +++ b/deploy/Dockerfile @@ -13,13 +13,28 @@ # limitations under the License. FROM golang:1.17 +WORKDIR /src # This arg is passed by docker buildx & contains the target CPU architecture (e.g., amd64, arm64, etc.) ARG TARGETARCH -WORKDIR /src -COPY . . +ENV GOARCH=$TARGETARCH +ENV CGO_ENABLED=0 +ENV GOBIN=/usr/local/bin + +# Get GCR credential helper +RUN go install github.com/GoogleCloudPlatform/docker-credential-gcr@4cdd60d0f2d8a69bc70933f4d7718f9c4e956ff8 + +# Get Amazon ECR credential helper +RUN go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@69c85dc22db6511932bbf119e1a0cc5c90c69a7f # v0.6.0 +# Get ACR docker env credential helper +RUN go install github.com/chrismellard/docker-credential-acr-env@09e2b5a8ac86c3ec347b2473e42b34367d8fa419 + +# Add .docker config dir +RUN mkdir -p /kaniko/.docker + +COPY . . RUN \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ @@ -36,11 +51,18 @@ RUN \ FROM scratch COPY --from=0 /src/out/executor /kaniko/executor -COPY files/nsswitch.conf /etc/nsswitch.conf +COPY --from=0 /usr/local/bin/docker-credential-gcr /kaniko/docker-credential-gcr +COPY --from=0 /usr/local/bin/docker-credential-ecr-login /kaniko/docker-credential-ecr-login +COPY --from=0 /usr/local/bin/docker-credential-acr-env /kaniko/docker-credential-acr-env COPY --from=certs /ca-certificates.crt /kaniko/ssl/certs/ +COPY --from=0 /kaniko/.docker /kaniko/.docker +COPY files/nsswitch.conf /etc/nsswitch.conf ENV HOME /root ENV USER root ENV PATH /usr/local/bin:/kaniko ENV SSL_CERT_DIR=/kaniko/ssl/certs +ENV DOCKER_CONFIG /kaniko/.docker/ +ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json +WORKDIR /workspace ENTRYPOINT ["/kaniko/executor"] diff --git a/deploy/Dockerfile_debug b/deploy/Dockerfile_debug index 77472b2b12..4368361af8 100644 --- a/deploy/Dockerfile_debug +++ b/deploy/Dockerfile_debug @@ -13,13 +13,28 @@ # limitations under the License. FROM golang:1.17 +WORKDIR /src # This arg is passed by docker buildx & contains the target CPU architecture (e.g., amd64, arm64, etc.) ARG TARGETARCH -WORKDIR /src -COPY . . +ENV GOARCH=$TARGETARCH +ENV CGO_ENABLED=0 +ENV GOBIN=/usr/local/bin + +# Get GCR credential helper +RUN go install github.com/GoogleCloudPlatform/docker-credential-gcr@4cdd60d0f2d8a69bc70933f4d7718f9c4e956ff8 + +# Get Amazon ECR credential helper +RUN go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@69c85dc22db6511932bbf119e1a0cc5c90c69a7f # v0.6.0 + +# Get ACR docker env credential helper +RUN go install github.com/chrismellard/docker-credential-acr-env@09e2b5a8ac86c3ec347b2473e42b34367d8fa419 +# Add .docker config dir +RUN mkdir -p /kaniko/.docker + +COPY . . RUN \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ @@ -38,13 +53,9 @@ RUN \ FROM scratch COPY --from=0 /src/out/executor /kaniko/executor COPY --from=0 /src/out/warmer /kaniko/warmer -COPY files/nsswitch.conf /etc/nsswitch.conf -COPY --from=certs /ca-certificates.crt /kaniko/ssl/certs/ -ENV HOME /root -ENV USER root -ENV PATH /usr/local/bin:/kaniko -ENV SSL_CERT_DIR=/kaniko/ssl/certs - +COPY --from=0 /usr/local/bin/docker-credential-gcr /kaniko/docker-credential-gcr +COPY --from=0 /usr/local/bin/docker-credential-ecr-login /kaniko/docker-credential-ecr-login +COPY --from=0 /usr/local/bin/docker-credential-acr-env /kaniko/docker-credential-acr-env COPY --from=busybox:1.32.0 /bin /busybox # Since busybox needs some lib files which lie in /lib directory to run the executables on s390x, # the below COPY command is added to address "ld64.so.1 not found" issue. This extra copy action will not @@ -53,7 +64,17 @@ COPY --from=busybox:1.32.0 /bin /busybox COPY --from=busybox:1.32.0 /*lib /lib # Declare /busybox as a volume to get it automatically in the path to ignore VOLUME /busybox + +COPY --from=certs /ca-certificates.crt /kaniko/ssl/certs/ +COPY --from=0 /kaniko/.docker /kaniko/.docker +COPY files/nsswitch.conf /etc/nsswitch.conf +ENV HOME /root +ENV USER root +ENV PATH /usr/local/bin:/kaniko:/busybox +ENV SSL_CERT_DIR=/kaniko/ssl/certs +ENV DOCKER_CONFIG /kaniko/.docker/ +ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json +WORKDIR /workspace RUN ["/busybox/mkdir", "-p", "/bin"] RUN ["/busybox/ln", "-s", "/busybox/sh", "/bin/sh"] - ENTRYPOINT ["/kaniko/executor"] diff --git a/deploy/Dockerfile_slim b/deploy/Dockerfile_slim index d0d3e960e2..e5bc222d3f 100644 --- a/deploy/Dockerfile_slim +++ b/deploy/Dockerfile_slim @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Builds the static Go image to execute in a Kubernetes job FROM golang:1.17 # This arg is passed by docker buildx & contains the target CPU architecture (e.g., amd64, arm64, etc.) @@ -44,3 +45,4 @@ ENV PATH /usr/local/bin:/kaniko ENV SSL_CERT_DIR=/kaniko/ssl/certs ENTRYPOINT ["/kaniko/executor"] + diff --git a/deploy/Dockerfile_warmer b/deploy/Dockerfile_warmer index 27db7efea9..f55124459e 100644 --- a/deploy/Dockerfile_warmer +++ b/deploy/Dockerfile_warmer @@ -13,13 +13,28 @@ # limitations under the License. FROM golang:1.17 +WORKDIR /src # This arg is passed by docker buildx & contains the target CPU architecture (e.g., amd64, arm64, etc.) ARG TARGETARCH -WORKDIR /src -COPY . . +ENV GOARCH=$TARGETARCH +ENV CGO_ENABLED=0 +ENV GOBIN=/usr/local/bin + +# Get GCR credential helper +RUN go install github.com/GoogleCloudPlatform/docker-credential-gcr@4cdd60d0f2d8a69bc70933f4d7718f9c4e956ff8 + +# Get Amazon ECR credential helper +RUN go install github.com/awslabs/amazon-ecr-credential-helper/ecr-login/cli/docker-credential-ecr-login@69c85dc22db6511932bbf119e1a0cc5c90c69a7f # v0.6.0 + +# Get ACR docker env credential helper +RUN go install github.com/chrismellard/docker-credential-acr-env@09e2b5a8ac86c3ec347b2473e42b34367d8fa419 +# Add .docker config dir +RUN mkdir -p /kaniko/.docker + +COPY . . RUN \ --mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/go/pkg \ @@ -36,11 +51,17 @@ RUN \ FROM scratch COPY --from=0 /src/out/warmer /kaniko/warmer -COPY files/nsswitch.conf /etc/nsswitch.conf +COPY --from=0 /usr/local/bin/docker-credential-gcr /kaniko/docker-credential-gcr +COPY --from=0 /usr/local/bin/docker-credential-ecr-login /kaniko/docker-credential-ecr-login +COPY --from=0 /usr/local/bin/docker-credential-acr-env /kaniko/docker-credential-acr-env COPY --from=certs /ca-certificates.crt /kaniko/ssl/certs/ +COPY --from=0 /kaniko/.docker /kaniko/.docker +COPY files/nsswitch.conf /etc/nsswitch.conf ENV HOME /root -ENV USER root +ENV USER /root ENV PATH /usr/local/bin:/kaniko ENV SSL_CERT_DIR=/kaniko/ssl/certs - +ENV DOCKER_CONFIG /kaniko/.docker/ +ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json +WORKDIR /workspace ENTRYPOINT ["/kaniko/warmer"]