From 51086e7327e179a47342fdc2a98ad6ab2fa7248f Mon Sep 17 00:00:00 2001 From: "L.Dongming" Date: Mon, 27 Nov 2023 17:49:48 +0800 Subject: [PATCH] chore: fix dev container image --- .devcontainer/devcontainer.json | 2 +- docker/Dockerfile-dev | 7 ++++--- docker/library-scripts/kubectl-helm-debian.sh | 21 +++++++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a2c482b28b0..e8faaed719a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,7 @@ // Uncomment to overwrite devcontainer .kube/config and .minikube certs with the localhost versions // each time the devcontainer starts, if the respective .kube-localhost/config and .minikube-localhost // folders respectively are bind mounted to the devcontainer. - "SYNC_LOCALHOST_KUBECONFIG": "true" + // "SYNC_LOCALHOST_KUBECONFIG": "true" // Uncomment to disable docker-in-docker and automatically proxy default /var/run/docker.sock to // the localhost bind-mount /var/run/docker-host.sock. diff --git a/docker/Dockerfile-dev b/docker/Dockerfile-dev index b4dd8dda53d..68dd7fe5b5b 100644 --- a/docker/Dockerfile-dev +++ b/docker/Dockerfile-dev @@ -14,7 +14,8 @@ ARG INSTALL_ZSH="true" ARG KUBECTL_VERSION="latest" ARG HELM_VERSION="latest" ARG MINIKUBE_VERSION="latest" -ARG GOLANGCI_LINT_VERSION="1.49.0" +ARG ETCD_VERSION="v3.5.10" +ARG GOLANGCI_LINT_VERSION="1.54.2" ARG USERNAME=kubeblocks ARG USER_UID=1000 @@ -42,8 +43,8 @@ RUN bash /tmp/library-scripts/setup-user.sh "${USERNAME}" "${PATH}" \ # Install Docker CLI and Engine for Docker-in-Docker (using Docker CE). && bash /tmp/library-scripts/docker-in-docker-debian.sh "true" "${USERNAME}" "false" "latest" \ # - # Install Kubectl, Helm and Minkikube. - && bash /tmp/library-scripts/kubectl-helm-debian.sh "${KUBECTL_VERSION}" "${HELM_VERSION}" "${MINIKUBE_VERSION}" \ + # Install Kubectl, Helm and Minikube. + && bash /tmp/library-scripts/kubectl-helm-debian.sh "${KUBECTL_VERSION}" "${HELM_VERSION}" "${MINIKUBE_VERSION}" "${ETCD_VERSION}"\ # # Install Go tools. && bash /tmp/library-scripts/go-debian.sh "none" "/usr/local/go" "/go" "${USERNAME}" "false" \ diff --git a/docker/library-scripts/kubectl-helm-debian.sh b/docker/library-scripts/kubectl-helm-debian.sh index 0c1bd32a5e1..2cb0226a8ce 100644 --- a/docker/library-scripts/kubectl-helm-debian.sh +++ b/docker/library-scripts/kubectl-helm-debian.sh @@ -33,10 +33,11 @@ set -e KUBECTL_VERSION="${1:-"latest"}" HELM_VERSION="${2:-"latest"}" MINIKUBE_VERSION="${3:-"none"}" # latest is also valid -KUBECTL_SHA256="${4:-"automatic"}" -HELM_SHA256="${5:-"automatic"}" -MINIKUBE_SHA256="${6:-"automatic"}" -USERNAME=${7:-"automatic"} +ETCD_VERSION="${4:-"none"}" +KUBECTL_SHA256="${5:-"automatic"}" +HELM_SHA256="${6:-"automatic"}" +MINIKUBE_SHA256="${7:-"automatic"}" +USERNAME=${8:-"automatic"} HELM_GPG_KEYS_URI="https://raw.githubusercontent.com/helm/helm/main/KEYS" GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com:80 @@ -162,6 +163,8 @@ fi if [ "${KUBECTL_VERSION::1}" != 'v' ]; then KUBECTL_VERSION="v${KUBECTL_VERSION}" fi + +echo "kubectl version: ${KUBECTL_VERSION}" curl -sSL -o /usr/local/bin/kubectl "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${architecture}/kubectl" chmod 0755 /usr/local/bin/kubectl if [ "$KUBECTL_SHA256" = "automatic" ]; then @@ -249,6 +252,16 @@ if [ "${MINIKUBE_VERSION}" != "none" ]; then fi fi +# Install etcd +if [ "${ETCD_VERSION}" != "none" ]; then + echo "Downloading etcd..." + curl -L "https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-${architecture}.tar.gz" -o "/tmp/etcd-${ETCD_VERSION}-linux-${architecture}.tar.gz" + tar xf "/tmp/etcd-${ETCD_VERSION}-linux-${architecture}.tar.gz" -C /tmp + mv -f "/tmp/etcd-${ETCD_VERSION}-linux-${architecture}/etcd" /usr/local/bin/etcd + mv -f "/tmp/etcd-${ETCD_VERSION}-linux-${architecture}/etcdctl" /usr/local/bin/etcdctl + rm -rf "/tmp/etcd-${ETCD_VERSION}-linux-${architecture}" +fi + if ! type docker > /dev/null 2>&1; then echo -e '\n(*) Warning: The docker command was not found.\n\nYou can use one of the following scripts to install it:\n\nhttps://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker-in-docker.md\n\nor\n\nhttps://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/docker.md' fi