|
| 1 | +# syntax=docker/dockerfile:1.2 |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +# See the License for the specific language governing permissions and |
| 17 | +# limitations under the License. |
| 18 | + |
| 19 | +ARG IMG_BASE='golang' |
| 20 | +ARG IMG_BASE_TAG='1.19-alpine' |
| 21 | +ARG BASE_IMG_ALPINE='alpine' |
| 22 | +ARG BASE_IMG_TAG_ALPINE='latest' |
| 23 | +ARG YQ_IMG='mikefarah/yq' |
| 24 | +ARG YQ_IMG_TAG='latest' |
| 25 | + |
| 26 | +FROM ${BASE_IMG_ALPINE}:${BASE_IMG_TAG_ALPINE} as alpine |
| 27 | + |
| 28 | +FROM ${YQ_IMG}:${YQ_IMG_TAG} as yq |
| 29 | + |
| 30 | +## -- Stages kubectl_${TARGETARCH} -- |
| 31 | +# Define stages that facilitate bringing in platform-specific binaries. |
| 32 | +FROM alpine as kubectl_amd64 |
| 33 | +ARG KUBECTL_SHA_AMD64 |
| 34 | +ARG KUBECTL_BIN_AMD64 |
| 35 | +WORKDIR /tmp/ |
| 36 | +COPY ${KUBECTL_SHA_AMD64} /tmp/ |
| 37 | +COPY ${KUBECTL_BIN_AMD64} /tmp/ |
| 38 | +RUN echo "$(cat "${KUBECTL_SHA_AMD64}") ${KUBECTL_BIN_AMD64}" | sha512sum -c |
| 39 | + |
| 40 | +FROM alpine as kubectl_arm64 |
| 41 | +ARG KUBECTL_SHA_ARM64 |
| 42 | +ARG KUBECTL_BIN_ARM64 |
| 43 | +WORKDIR /tmp/ |
| 44 | +COPY ${KUBECTL_SHA_ARM64} /tmp/ |
| 45 | +COPY ${KUBECTL_BIN_ARM64} /tmp/ |
| 46 | +RUN echo "$(cat "${KUBECTL_SHA_ARM64}") ${KUBECTL_BIN_ARM64}" | sha512sum -c |
| 47 | + |
| 48 | +ARG TARGETARCH |
| 49 | +FROM kubectl_${TARGETARCH} as kubectl |
| 50 | +RUN mv /tmp/kubectl_* /tmp/kubectl \ |
| 51 | + && chmod a+x /tmp/kubectl |
| 52 | + |
| 53 | +## -- Stages kuttl_${TARGETARCH} -- |
| 54 | +# Define stages that facilitate bringing in platform-specific binaries. |
| 55 | +FROM alpine as kuttl_amd64 |
| 56 | +ARG KUTTL_CHECKSUMS |
| 57 | +ARG KUTTL_BIN_AMD64 |
| 58 | +WORKDIR /tmp/ |
| 59 | +COPY ${KUTTL_CHECKSUMS} /tmp/ |
| 60 | +COPY ${KUTTL_BIN_AMD64} /tmp/ |
| 61 | +RUN sha256sum -c <(grep "${KUTTL_BIN_AMD64}" "${KUTTL_CHECKSUMS}") |
| 62 | + |
| 63 | +FROM alpine as kuttl_arm64 |
| 64 | +ARG KUTTL_CHECKSUMS |
| 65 | +ARG KUTTL_BIN_ARM64 |
| 66 | +WORKDIR /tmp/ |
| 67 | +COPY ${KUTTL_CHECKSUMS} /tmp/ |
| 68 | +COPY ${KUTTL_BIN_ARM64} /tmp/ |
| 69 | +RUN sha256sum -c <(grep "${KUTTL_BIN_ARM64}" "${KUTTL_CHECKSUMS}") |
| 70 | + |
| 71 | +ARG TARGETARCH |
| 72 | +FROM kuttl_${TARGETARCH} as kuttl |
| 73 | +RUN mv /tmp/kubectl-kuttl_* /tmp/kubectl-kuttl \ |
| 74 | + && chmod a+x /tmp/kubectl-kuttl |
| 75 | + |
| 76 | +## -- Stages kustomize_${TARGETARCH} -- |
| 77 | +# Define stages that facilitate bringing in platform-specific binaries. |
| 78 | +FROM alpine as kustomize_amd64 |
| 79 | +ARG KUSTOMIZE_CHECKSUMS |
| 80 | +ARG KUSTOMIZE_BIN_AMD64_TGZ |
| 81 | +WORKDIR /tmp/ |
| 82 | +COPY ${KUSTOMIZE_CHECKSUMS} /tmp/ |
| 83 | +COPY ${KUSTOMIZE_BIN_AMD64_TGZ} /tmp/ |
| 84 | +RUN sha256sum -c <(grep "${KUSTOMIZE_BIN_AMD64_TGZ}" "${KUSTOMIZE_CHECKSUMS}") \ |
| 85 | + && cd /tmp \ |
| 86 | + && tar xzf "${KUSTOMIZE_BIN_AMD64_TGZ}" |
| 87 | + |
| 88 | +FROM alpine as kustomize_arm64 |
| 89 | +ARG KUSTOMIZE_CHECKSUMS |
| 90 | +ARG KUSTOMIZE_BIN_ARM64_TGZ |
| 91 | +WORKDIR /tmp/ |
| 92 | +COPY ${KUSTOMIZE_CHECKSUMS} /tmp/ |
| 93 | +COPY ${KUSTOMIZE_BIN_ARM64_TGZ} /tmp/ |
| 94 | +RUN sha256sum -c <(grep "${KUSTOMIZE_BIN_ARM64_TGZ}" "${KUSTOMIZE_CHECKSUMS}") |
| 95 | + |
| 96 | +ARG TARGETARCH |
| 97 | +FROM kustomize_${TARGETARCH} as kustomize |
| 98 | +RUN tar xzf /tmp/kustomize_*.tar.gz \ |
| 99 | + && chmod a+x /tmp/kustomize |
| 100 | + |
| 101 | +## -- Stage aws_cli_builder |
| 102 | +FROM alpine as aws_cli_builder |
| 103 | +ARG AWS_CLI_PUBLIC_KEY |
| 104 | +ARG AWS_CLI_SOURCES_TGZ |
| 105 | +ARG AWS_CLI_SOURCES_TGZ_SIG |
| 106 | +COPY ${AWS_CLI_PUBLIC_KEY} /tmp/ |
| 107 | +COPY ${AWS_CLI_SOURCES_TGZ} /tmp/ |
| 108 | +COPY ${AWS_CLI_SOURCES_TGZ_SIG} /tmp/ |
| 109 | +WORKDIR /tmp |
| 110 | +RUN apk add --no-cache \ |
| 111 | + build-base \ |
| 112 | + cmake \ |
| 113 | + gnupg \ |
| 114 | + groff \ |
| 115 | + libffi-dev \ |
| 116 | + python3 \ |
| 117 | + python3-dev \ |
| 118 | + tar \ |
| 119 | + && gpg --import /tmp/aws_cli_public_key \ |
| 120 | + && gpg --verify /tmp/${AWS_CLI_SOURCES_TGZ_SIG} /tmp/${AWS_CLI_SOURCES_TGZ} \ |
| 121 | + && tar -xzf ${AWS_CLI_SOURCES_TGZ} \ |
| 122 | + && cd "${AWS_CLI_SOURCES_TGZ%.tar.gz}" \ |
| 123 | + && ./configure --with-install-type=portable-exe --with-download-deps \ |
| 124 | + && make \ |
| 125 | + && make install \ |
| 126 | + && rm -rf \ |
| 127 | + /usr/local/lib/aws-cli/aws_completer \ |
| 128 | + /usr/local/lib/aws-cli/awscli/data/ac.index \ |
| 129 | + /usr/local/lib/aws-cli/awscli/examples \ |
| 130 | + && find /usr/local/lib/aws-cli/awscli/data -name completions-1*.json -delete \ |
| 131 | + && find /usr/local/lib/aws-cli/awscli/botocore/data -name examples-1.json -delete \ |
| 132 | + && cd /usr/local/lib/aws-cli \ |
| 133 | + && for a in *.so* ; do test -f /lib/$a && rm $a; done |
| 134 | + |
| 135 | +FROM ${IMG_BASE}:${IMG_BASE_TAG} as final |
| 136 | +ARG IMG_BASE |
| 137 | +ARG IMG_BASE_TAG |
| 138 | + |
| 139 | +COPY --from=yq /usr/bin/yq /usr/bin/yq |
| 140 | +COPY --from=kubectl /tmp/kubectl /usr/local/bin/ |
| 141 | +COPY --from=kuttl /tmp/kubectl-kuttl /usr/local/bin/ |
| 142 | +COPY --from=kustomize /tmp/kustomize /usr/local/bin/ |
| 143 | +COPY --from=aws_cli_builder /usr/local/lib/aws-cli/ /usr/local/lib/aws-cli/ |
| 144 | +COPY hbase-kubernetes-deployment/dockerfiles/kuttl/entrypoint.sh /bin/ |
| 145 | + |
| 146 | +# install python, needed by aws-cli |
| 147 | +ENV LANG C.UTF-8 |
| 148 | +RUN apk add --update --no-cache \ |
| 149 | + bash \ |
| 150 | + docker-cli \ |
| 151 | + groff \ |
| 152 | + less \ |
| 153 | + python3 \ |
| 154 | + python3-dev \ |
| 155 | + && ln -s /usr/local/lib/aws-cli/aws /usr/local/bin/aws \ |
| 156 | + && /usr/local/bin/aws --version |
| 157 | + |
| 158 | +# replicate the test-related bits generated by `kubebuilder` into its Makefile. |
| 159 | +ENV GOBIN="${GOPATH}/bin" |
| 160 | +ENV ENVTEST_K8S_VERSION='1.23.x' |
| 161 | +RUN chmod a+x /bin/entrypoint.sh \ |
| 162 | + && go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest \ |
| 163 | + && "${GOBIN}/setup-envtest" use "${ENVTEST_K8S_VERSION}" |
| 164 | +# disable downloading remote content henceforth |
| 165 | +ENV ENVTEST_INSTALLED_ONLY=true |
| 166 | + |
| 167 | +ENTRYPOINT ["/bin/entrypoint.sh"] |
0 commit comments