Skip to content

Commit

Permalink
chore: fix dev container image
Browse files Browse the repository at this point in the history
  • Loading branch information
ldming committed Nov 27, 2023
1 parent 4934ee6 commit 51086e7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions docker/Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" \
Expand Down
21 changes: 17 additions & 4 deletions docker/library-scripts/kubectl-helm-debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 51086e7

Please sign in to comment.