From 9aa52863854c19a0bb2852b06bb86a614c9109d3 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Fri, 5 Jul 2024 08:22:36 +1000 Subject: [PATCH] chore: allow docker-host to be configurable --- Dockerfile | 1 + legacy/Dockerfile.kubectl | 61 --------------------- legacy/Dockerfile.kubectl-build-deploy-dind | 35 ------------ legacy/docker-entrypoint.sh | 8 +-- 4 files changed, 5 insertions(+), 100 deletions(-) delete mode 100644 legacy/Dockerfile.kubectl delete mode 100644 legacy/Dockerfile.kubectl-build-deploy-dind diff --git a/Dockerfile b/Dockerfile index 2574e48b..46ef26ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -103,6 +103,7 @@ COPY legacy/scripts /kubectl-build-deploy/scripts COPY legacy/helmcharts /kubectl-build-deploy/helmcharts ENV DBAAS_OPERATOR_HTTP=dbaas.lagoon.svc:5000 +ENV DOCKER_HOST=docker-host.lagoon.svc RUN architecture=$(case $(uname -m) in x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \ && curl -sSL https://github.com/uselagoon/lagoon-linter/releases/download/v0.8.0/lagoon-linter_0.8.0_linux_${architecture}.tar.gz \ diff --git a/legacy/Dockerfile.kubectl b/legacy/Dockerfile.kubectl deleted file mode 100644 index aa8b3ab6..00000000 --- a/legacy/Dockerfile.kubectl +++ /dev/null @@ -1,61 +0,0 @@ -ARG UPSTREAM_REPO -ARG UPSTREAM_TAG -FROM ${UPSTREAM_REPO:-uselagoon}/commons:${UPSTREAM_TAG:-latest} as commons -FROM golang:1.18-alpine as golang - -RUN apk add --no-cache git -RUN go get github.com/a8m/envsubst/cmd/envsubst - -FROM docker:20.10.14 - -LABEL maintainer="amazee.io" -ENV LAGOON=oc - -COPY --from=golang /go/bin/envsubst /bin/envsubst - -ARG LAGOON_VERSION -ENV LAGOON_VERSION=$LAGOON_VERSION - -# Copy commons files -COPY --from=commons /lagoon /lagoon -COPY --from=commons /bin/fix-permissions /bin/ep /bin/docker-sleep /bin/ -COPY --from=commons /sbin/tini /sbin/ -COPY --from=commons /home /home - -RUN chmod g+w /etc/passwd \ - && mkdir -p /home - -ENV TMPDIR=/tmp \ - TMP=/tmp \ - HOME=/home \ - # When Bash is invoked via `sh` it behaves like the old Bourne Shell and sources a file that is given in `ENV` - ENV=/home/.bashrc \ - # When Bash is invoked as non-interactive (like `bash -c command`) it sources a file that is given in `BASH_ENV` - BASH_ENV=/home/.bashrc - -# Defining Versions -ENV KUBECTL_VERSION=v1.20.4 \ - HELM_VERSION=v3.5.2 \ - HELM_SHA256=01b317c506f8b6ad60b11b1dc3f093276bb703281cb1ae01132752253ec706a2 - -RUN apk add -U --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing aufs-util \ - && apk add --update openssl curl jq parallel \ - && apk add --no-cache bash git openssh py-pip skopeo \ - && git config --global user.email "lagoon@lagoon.io" && git config --global user.name lagoon \ - && pip install shyaml yq \ - && curl -Lo /usr/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl \ - && chmod +x /usr/bin/kubectl \ - && curl -Lo /usr/bin/yq3 https://github.com/mikefarah/yq/releases/download/3.3.2/yq_linux_amd64 \ - && chmod +x /usr/bin/yq3 \ - && curl -Lo /usr/bin/yq https://github.com/mikefarah/yq/releases/download/v4.15.1/yq_linux_amd64 \ - && chmod +x /usr/bin/yq \ - && curl -Lo /tmp/helm.tar.gz https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz \ - && echo "${HELM_SHA256} /tmp/helm.tar.gz" | sha256sum -c - \ - && mkdir /tmp/helm \ - && tar -xzf /tmp/helm.tar.gz -C /tmp/helm --strip-components=1 \ - && mv /tmp/helm/helm /usr/bin/helm \ - && chmod +x /usr/bin/helm \ - && rm -rf /tmp/helm* - - -ENTRYPOINT ["/sbin/tini", "--", "/lagoon/entrypoints.sh"] diff --git a/legacy/Dockerfile.kubectl-build-deploy-dind b/legacy/Dockerfile.kubectl-build-deploy-dind deleted file mode 100644 index 0b7724a7..00000000 --- a/legacy/Dockerfile.kubectl-build-deploy-dind +++ /dev/null @@ -1,35 +0,0 @@ -ARG IMAGE_REPO -ARG UPSTREAM_TAG -FROM ${IMAGE_REPO:-lagoon}/kubectl:${UPSTREAM_TAG:-legacy} - -ENV LAGOON=kubectl-build-deploy-dind - -RUN mkdir -p /kubectl-build-deploy/git -RUN mkdir -p /kubectl-build-deploy/lagoon - -WORKDIR /kubectl-build-deploy/git - -COPY docker-entrypoint.sh /lagoon/entrypoints/100-docker-entrypoint.sh -COPY build-deploy.sh /kubectl-build-deploy/build-deploy.sh -COPY build-deploy-docker-compose.sh /kubectl-build-deploy/build-deploy-docker-compose.sh -COPY rootless.values.yaml /kubectl-build-deploy/rootless.values.yaml - -COPY scripts /kubectl-build-deploy/scripts - -COPY helmcharts /kubectl-build-deploy/helmcharts - -ENV DBAAS_OPERATOR_HTTP=dbaas.lagoon.svc:5000 - -RUN curl -sSL https://github.com/uselagoon/lagoon-linter/releases/download/v0.7.0/lagoon-linter_0.7.0_linux_amd64.tar.gz \ - | tar -xz -C /usr/local/bin lagoon-linter - -RUN curl -sSL https://github.com/uselagoon/build-deploy-tool/releases/download/v0.11.0/build-deploy-tool_0.11.0_linux_amd64.tar.gz \ - | tar -xz -C /usr/local/bin build-deploy-tool - -RUN curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin > /dev/null 2>&1 -#curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin > /dev/null 2>&1 - -# enable running unprivileged -RUN fix-permissions /home && fix-permissions /kubectl-build-deploy - -CMD ["/kubectl-build-deploy/build-deploy.sh"] diff --git a/legacy/docker-entrypoint.sh b/legacy/docker-entrypoint.sh index 0cb9f09d..1bf156a4 100755 --- a/legacy/docker-entrypoint.sh +++ b/legacy/docker-entrypoint.sh @@ -4,18 +4,18 @@ set -e # try connect to docker-host 10 times before giving up DOCKER_HOST_COUNTER=1 DOCKER_HOST_TIMEOUT=10 -until docker -H docker-host.lagoon.svc info &> /dev/null +until docker -H ${DOCKER_HOST} info &> /dev/null do if [ $DOCKER_HOST_COUNTER -lt $DOCKER_HOST_TIMEOUT ]; then let DOCKER_HOST_COUNTER=DOCKER_HOST_COUNTER+1 - echo "docker-host.lagoon.svc not available yet, waiting for 5 secs" + echo "${DOCKER_HOST} not available yet, waiting for 5 secs" sleep 5 else - echo "could not connect to docker-host.lagoon.svc" + echo "could not connect to ${DOCKER_HOST}" exit 1 fi done -export DOCKER_HOST=docker-host.lagoon.svc + mkdir -p ~/.ssh