Skip to content

Commit 6115213

Browse files
Copilotchefgs
andauthored
Update devcontainer kubectl installation to use supported release downloads (#66)
* Update kubectl repo path in devcontainer Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/8929bee2-ec5e-454a-8614-f771484942ab Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Use direct kubectl release download in devcontainer Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/8929bee2-ec5e-454a-8614-f771484942ab Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Harden kubectl checksum verification Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/8929bee2-ec5e-454a-8614-f771484942ab Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Clarify kubectl checksum failure output Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/8929bee2-ec5e-454a-8614-f771484942ab Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Support arch-aware kubectl downloads Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/8929bee2-ec5e-454a-8614-f771484942ab Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Improve kubectl download diagnostics Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/8929bee2-ec5e-454a-8614-f771484942ab Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Refine kubectl failure messages Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/8929bee2-ec5e-454a-8614-f771484942ab Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Polish kubectl error message casing Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/8929bee2-ec5e-454a-8614-f771484942ab Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Audit and refresh devcontainer install URLs Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/5a7ec5cb-5911-4929-a875-d57261636b95 Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Fix PMD extracted directory pattern Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/5a7ec5cb-5911-4929-a875-d57261636b95 Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Tighten Sonar and PMD install steps Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/5a7ec5cb-5911-4929-a875-d57261636b95 Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com>
1 parent ec5369c commit 6115213

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ ARG PYTHON_VERSION=3.11
66
ARG JAVA_VERSION=17
77
ARG NODE_VERSION=20
88
ARG GO_VERSION=1.21
9+
ARG TARGETOS=linux
10+
ARG TARGETARCH=amd64
911
ARG INSTALL_PYTHON=true
1012
ARG INSTALL_JAVA=true
1113
ARG INSTALL_JS=true
@@ -28,6 +30,7 @@ ARG INSTALL_KUBESEAL=true
2830
ARG INSTALL_FLUX=true
2931
ARG FLUX_VERSION=2.1.2
3032
ARG INSTALL_KIND=true
33+
ARG KIND_VERSION=0.20.0
3134
ARG INSTALL_MINIKUBE=true
3235
ARG INSTALL_OPENSHIFT_CLI=false
3336

@@ -40,8 +43,10 @@ ARG INSTALL_CMAKE=true
4043

4144
# Code analysis tools
4245
ARG INSTALL_SONARQUBE=true
46+
ARG SONAR_SCANNER_VERSION=4.8.0.2856
4347
ARG INSTALL_CHECKSTYLE=true
4448
ARG INSTALL_PMD=true
49+
ARG PMD_VERSION=7.0.0-rc3
4550
ARG INSTALL_ESLINT=true
4651
ARG INSTALL_PYLINT=true
4752

@@ -123,10 +128,14 @@ RUN if [ "$INSTALL_TERRAFORM" = "true" ]; then \
123128

124129
# Install kubectl if requested
125130
RUN if [ "$INSTALL_KUBECTL" = "true" ]; then \
126-
curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg \
127-
&& echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list \
128-
&& apt-get update \
129-
&& apt-get install -y kubectl; \
131+
KUBECTL_VERSION="$(curl -fsSL https://dl.k8s.io/release/stable.txt)" || (echo "Failed to resolve the latest kubectl version from https://dl.k8s.io/release/stable.txt" >&2 && exit 1) \
132+
&& curl -fsSLo /tmp/kubectl "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/${TARGETOS}/${TARGETARCH}/kubectl" \
133+
&& curl -fsSLo /tmp/kubectl.sha256 "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/${TARGETOS}/${TARGETARCH}/kubectl.sha256" \
134+
&& KUBECTL_SHA256="$(cat /tmp/kubectl.sha256)" \
135+
&& DOWNLOADED_KUBECTL_SHA256="$(sha256sum /tmp/kubectl | cut -d' ' -f1)" \
136+
&& (test "${KUBECTL_SHA256}" = "${DOWNLOADED_KUBECTL_SHA256}" || (echo "Kubectl checksum verification failed: expected ${KUBECTL_SHA256}, got ${DOWNLOADED_KUBECTL_SHA256}" >&2 && exit 1)) \
137+
&& install -o root -g root -m 0755 /tmp/kubectl /usr/local/bin/kubectl \
138+
&& rm -f /tmp/kubectl /tmp/kubectl.sha256; \
130139
fi
131140

132141
# Install Helm if requested
@@ -187,7 +196,7 @@ RUN if [ "$INSTALL_FLUX" = "true" ]; then \
187196

188197
# Install KinD if requested
189198
RUN if [ "$INSTALL_KIND" = "true" ]; then \
190-
curl -Lo /usr/local/bin/kind "https://kind.sigs.k8s.io/dl/v0.20.0/kind-$(uname)-amd64" \
199+
curl -fsSLo /usr/local/bin/kind "https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-${TARGETOS}-${TARGETARCH}" \
191200
&& chmod +x /usr/local/bin/kind; \
192201
fi
193202

@@ -239,11 +248,12 @@ RUN if [ "$INSTALL_ANT" = "true" ]; then \
239248

240249
# SonarQube Scanner
241250
RUN if [ "$INSTALL_SONARQUBE" = "true" ]; then \
242-
mkdir -p /opt/sonar-scanner \
243-
&& curl -sSLo /opt/sonar-scanner-cli.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip \
244-
&& unzip /opt/sonar-scanner-cli.zip -d /opt \
245-
&& mv /opt/sonar-scanner-* /opt/sonar-scanner \
246-
&& rm /opt/sonar-scanner-cli.zip \
251+
curl -fsSLo /tmp/sonar-scanner-cli.zip "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip" \
252+
&& rm -rf /opt/sonar-scanner \
253+
&& mkdir -p /tmp/sonar-scanner \
254+
&& unzip /tmp/sonar-scanner-cli.zip -d /tmp/sonar-scanner \
255+
&& mv "/tmp/sonar-scanner/sonar-scanner-${SONAR_SCANNER_VERSION}-linux" /opt/sonar-scanner \
256+
&& rm -rf /tmp/sonar-scanner /tmp/sonar-scanner-cli.zip \
247257
&& echo 'export PATH=$PATH:/opt/sonar-scanner/bin' >> /etc/bash.bashrc; \
248258
fi
249259

@@ -258,9 +268,9 @@ RUN if [ "$INSTALL_CHECKSTYLE" = "true" ]; then \
258268
# PMD
259269
RUN if [ "$INSTALL_PMD" = "true" ]; then \
260270
mkdir -p /opt/pmd \
261-
&& curl -sSLo /opt/pmd.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F7.0.0-rc3/pmd-bin-7.0.0-rc3.zip \
271+
&& curl -fsSLo /opt/pmd.zip "https://github.com/pmd/pmd/releases/download/pmd_releases/${PMD_VERSION}/pmd-dist-${PMD_VERSION}-bin.zip" \
262272
&& unzip /opt/pmd.zip -d /opt \
263-
&& mv /opt/pmd-bin-* /opt/pmd \
273+
&& mv "/opt/pmd-bin-${PMD_VERSION}" /opt/pmd \
264274
&& rm /opt/pmd.zip \
265275
&& echo 'export PATH=$PATH:/opt/pmd/bin' >> /etc/bash.bashrc; \
266276
fi
@@ -302,8 +312,8 @@ RUN if [ "$INSTALL_PROMETHEUS" = "true" ]; then \
302312

303313
# Grafana
304314
RUN if [ "$INSTALL_GRAFANA" = "true" ]; then \
305-
wget -q -O - https://packages.grafana.com/gpg.key | gpg --dearmor | tee /usr/share/keyrings/grafana.gpg > /dev/null \
306-
&& echo "deb [signed-by=/usr/share/keyrings/grafana.gpg] https://packages.grafana.com/oss/deb stable main" | tee -a /etc/apt/sources.list.d/grafana.list \
315+
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | tee /usr/share/keyrings/grafana.gpg > /dev/null \
316+
&& echo "deb [signed-by=/usr/share/keyrings/grafana.gpg] https://apt.grafana.com stable main" | tee -a /etc/apt/sources.list.d/grafana.list \
307317
&& apt-get update \
308318
&& apt-get install -y grafana; \
309319
fi

0 commit comments

Comments
 (0)