From ca69432bf807446c6c6bb9204447add5e0f0056a Mon Sep 17 00:00:00 2001 From: Viktor Nagy Date: Tue, 3 Sep 2024 15:27:06 +0200 Subject: [PATCH 1/3] Add devcontainer support --- Devcontainer.Dockerfile | 23 +++++++++++++++++++++++ devcontainer.json | 11 +++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Devcontainer.Dockerfile create mode 100644 devcontainer.json diff --git a/Devcontainer.Dockerfile b/Devcontainer.Dockerfile new file mode 100644 index 000000000..bdb71f381 --- /dev/null +++ b/Devcontainer.Dockerfile @@ -0,0 +1,23 @@ +FROM golang:alpine + +RUN apk add --no-cache bash \ + curl \ + git \ + make \ + jq + +# Install kubectl +RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl +RUN chmod +x ./kubectl +RUN mv ./kubectl /usr/local/bin + +# Install Flux CLI +RUN FLUX_LATEST=$(curl -s https://api.github.com/repos/fluxcd/flux2/releases/latest | jq -r .tag_name) && \ + FLUX_VERSION=${FLUX_LATEST#v} && \ + curl -L https://github.com/fluxcd/flux2/releases/download/${FLUX_LATEST}/flux_${FLUX_VERSION}_linux_amd64.tar.gz -o flux.tar.gz && \ + tar -xzf flux.tar.gz && \ + mv flux /usr/local/bin/ && \ + rm flux.tar.gz + +# to make the build succeed +RUN git config --global --add safe.directory /workspaces/glab diff --git a/devcontainer.json b/devcontainer.json new file mode 100644 index 000000000..5c29be389 --- /dev/null +++ b/devcontainer.json @@ -0,0 +1,11 @@ +{ + "build": { + // Path is relative to the devcontainer.json file. + "dockerfile": "Devcontainer.Dockerfile" + }, + "features": { + "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {} + }, + // Use 'postStartCommand' to run commands after the container is created like starting minikube. + "postStartCommand": "nohup bash -c 'minikube start &' > minikube.log 2>&1" +} \ No newline at end of file -- GitLab From 72f4cd007d1c62463aeec9a0fc1d5d5e83c43203 Mon Sep 17 00:00:00 2001 From: "Viktor Nagy (GitLab)" Date: Wed, 4 Sep 2024 06:19:47 +0000 Subject: [PATCH 2/3] Simplified devcontainer --- Devcontainer.Dockerfile | 23 --------------------- devcontainer.json | 45 ++++++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 33 deletions(-) delete mode 100644 Devcontainer.Dockerfile diff --git a/Devcontainer.Dockerfile b/Devcontainer.Dockerfile deleted file mode 100644 index bdb71f381..000000000 --- a/Devcontainer.Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -FROM golang:alpine - -RUN apk add --no-cache bash \ - curl \ - git \ - make \ - jq - -# Install kubectl -RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl -RUN chmod +x ./kubectl -RUN mv ./kubectl /usr/local/bin - -# Install Flux CLI -RUN FLUX_LATEST=$(curl -s https://api.github.com/repos/fluxcd/flux2/releases/latest | jq -r .tag_name) && \ - FLUX_VERSION=${FLUX_LATEST#v} && \ - curl -L https://github.com/fluxcd/flux2/releases/download/${FLUX_LATEST}/flux_${FLUX_VERSION}_linux_amd64.tar.gz -o flux.tar.gz && \ - tar -xzf flux.tar.gz && \ - mv flux /usr/local/bin/ && \ - rm flux.tar.gz - -# to make the build succeed -RUN git config --global --add safe.directory /workspaces/glab diff --git a/devcontainer.json b/devcontainer.json index 5c29be389..0453bbe98 100644 --- a/devcontainer.json +++ b/devcontainer.json @@ -1,11 +1,36 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/kubernetes-helm-minikube { - "build": { - // Path is relative to the devcontainer.json file. - "dockerfile": "Devcontainer.Dockerfile" - }, - "features": { - "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {} - }, - // Use 'postStartCommand' to run commands after the container is created like starting minikube. - "postStartCommand": "nohup bash -c 'minikube start &' > minikube.log 2>&1" -} \ No newline at end of file + "name": "Kubernetes - Minikube-in-Docker", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/go", + + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "enableNonRootDocker": "true", + "moby": "true" + }, + "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { + "version": "latest", + "helm": "latest", + "minikube": "latest" + }, + "ghcr.io/goldsam/dev-container-features/flux2:1": {} + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "kubectl version", + + // Use 'postStartCommand' to run commands after the container is created like starting minikube. + "postStartCommand": "git config --global --add safe.directory /workspaces/glab; nohup bash -c 'minikube start &' > minikube.log 2>&1" + // "postStartCommand": "nohup bash -c 'minikube start &' > minikube.log 2>&1", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} -- GitLab From 3fb2e429ec5f79e2acabab526fb6b90008d0a71e Mon Sep 17 00:00:00 2001 From: "Viktor Nagy (GitLab)" Date: Wed, 4 Sep 2024 06:23:10 +0000 Subject: [PATCH 3/3] Renamed devcontainer --- devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devcontainer.json b/devcontainer.json index 0453bbe98..270ab4410 100644 --- a/devcontainer.json +++ b/devcontainer.json @@ -1,7 +1,7 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/kubernetes-helm-minikube { - "name": "Kubernetes - Minikube-in-Docker", + "name": "Go dev environment with Minikube", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/go", -- GitLab