From f0b51aebb5da0f1456c9213d8a90f1cd4b780cc7 Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Tue, 1 Apr 2025 08:00:50 +0000 Subject: [PATCH 1/7] Remove Gitpod setup in favor of DevContainer setup --- .../Dockerfile | 8 ++++++++ .devcontainer/devcontainer.json | 4 ++-- .gitpod.yml | 20 ------------------- 3 files changed, 10 insertions(+), 22 deletions(-) rename .gitpod.Dockerfile => .devcontainer/Dockerfile (79%) delete mode 100644 .gitpod.yml diff --git a/.gitpod.Dockerfile b/.devcontainer/Dockerfile similarity index 79% rename from .gitpod.Dockerfile rename to .devcontainer/Dockerfile index 675d3f97..da057cf1 100644 --- a/.gitpod.Dockerfile +++ b/.devcontainer/Dockerfile @@ -50,3 +50,11 @@ RUN go install -v github.com/uudashr/gopkgs/cmd/gopkgs@v2 \ ENV SHFMT_VERSION=3.10.0 RUN curl -sSL -o /usr/local/bin/shfmt "https://github.com/mvdan/sh/releases/download/v${SHFMT_VERSION}/shfmt_v${SHFMT_VERSION}_linux_amd64" && \ chmod 755 /usr/local/bin/shfmt + +# Install latest Leeway release +RUN . /tmp/go_platform.env && \ + LATEST_LEEWAY_VERSION=$(curl -s https://api.github.com/repos/gitpod-io/leeway/releases/latest | grep '"tag_name"' | sed 's/.*"tag_name": "v\([^"]*\)".*/\1/') && \ + curl -L -o /tmp/leeway.tar.gz https://github.com/gitpod-io/leeway/releases/download/v${LATEST_LEEWAY_VERSION}/leeway_Linux_${GO_PLATFORM#linux-}.tar.gz && \ + tar -xzf /tmp/leeway.tar.gz -C /tmp && \ + install -m 755 /tmp/leeway /usr/local/bin/ && \ + rm /tmp/leeway.tar.gz diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a74abd42..525e6386 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ "name": "leeway", "build": { "context": "..", - "dockerfile": "../.gitpod.Dockerfile" + "dockerfile": "Dockerfile" }, "runArgs": [ "--privileged", @@ -10,4 +10,4 @@ "--network=host" ], "containerUser": "root" -} \ No newline at end of file +} diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 140dff50..00000000 --- a/.gitpod.yml +++ /dev/null @@ -1,20 +0,0 @@ - -checkoutLocation: leeway -workspaceLocation: leeway - -image: - file: .gitpod.Dockerfile - -# List the ports you want to expose and what to do when they are served. See https://www.gitpod.io/docs/43_config_ports/ -ports: -- port: 3000 - -# List the start up tasks. You can start them in parallel in multiple terminals. See https://www.gitpod.io/docs/44_config_start_tasks/ -tasks: -- init: | - git config core.hooksPath .githooks; - go generate -v ./... -vscode: - extensions: - - golang.go - - eamodio.gitlens From 8c4812f7027b5349b8c0625ce8e1a208c48d204e Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Tue, 1 Apr 2025 08:02:42 +0000 Subject: [PATCH 2/7] Move dependency installation from Dockefile to devcontainer.json --- .devcontainer/Dockerfile | 57 +++------------------------------ .devcontainer/devcontainer.json | 24 +++++++++++++- 2 files changed, 27 insertions(+), 54 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index da057cf1..a66c43bf 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,60 +1,11 @@ FROM ubuntu:jammy -ADD https://raw.githubusercontent.com/gitpod-io/workspace-images/main/base/install-packages /usr/bin/install-packages -RUN chmod +x /usr/bin/install-packages - -RUN install-packages \ - zip unzip \ - jq \ - curl \ - ca-certificates \ - file \ - git \ - node.js - -ENV GO_VERSION=1.24.0 -RUN echo "TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}" && \ - case "${TARGETPLATFORM:-linux/amd64}" in \ - "linux/arm64") \ - echo "GO_PLATFORM=linux-arm64" > /tmp/go_platform.env \ - ;; \ - *) \ - echo "GO_PLATFORM=linux-amd64" > /tmp/go_platform.env \ - ;; \ - esac - -# Install Go and add it to PATH -RUN . /tmp/go_platform.env && \ - curl -fsSL https://dl.google.com/go/go$GO_VERSION.$GO_PLATFORM.tar.gz | tar -C /usr/local -xzs - -# Set Go environment variables -ENV GOROOT=/usr/local/go -ENV PATH=$GOROOT/bin:$PATH -ENV GOPATH=/root/go -ENV PATH=$GOPATH/bin:$PATH - -# install VS Code Go tools for use with gopls as per https://github.com/golang/vscode-go/blob/master/docs/tools.md -# also https://github.com/golang/vscode-go/blob/27bbf42a1523cadb19fad21e0f9d7c316b625684/src/goTools.ts#L139 -RUN go install -v github.com/uudashr/gopkgs/cmd/gopkgs@v2 \ - && go install -v github.com/ramya-rao-a/go-outline@latest \ - && go install -v github.com/cweill/gotests/gotests@latest \ - && go install -v github.com/fatih/gomodifytags@latest \ - && go install -v github.com/josharian/impl@latest \ - && go install -v github.com/haya14busa/goplay/cmd/goplay@latest \ - && go install -v github.com/go-delve/delve/cmd/dlv@latest \ - && go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest \ - && go install -v golang.org/x/tools/gopls@latest \ - && go install -v honnef.co/go/tools/cmd/staticcheck@latest \ - && rm -rf /root/.cache - -ENV SHFMT_VERSION=3.10.0 -RUN curl -sSL -o /usr/local/bin/shfmt "https://github.com/mvdan/sh/releases/download/v${SHFMT_VERSION}/shfmt_v${SHFMT_VERSION}_linux_amd64" && \ - chmod 755 /usr/local/bin/shfmt - # Install latest Leeway release -RUN . /tmp/go_platform.env && \ +ENV GO_PLATFORM=linux-amd64 +RUN apt-get update && apt-get install -y curl && \ LATEST_LEEWAY_VERSION=$(curl -s https://api.github.com/repos/gitpod-io/leeway/releases/latest | grep '"tag_name"' | sed 's/.*"tag_name": "v\([^"]*\)".*/\1/') && \ curl -L -o /tmp/leeway.tar.gz https://github.com/gitpod-io/leeway/releases/download/v${LATEST_LEEWAY_VERSION}/leeway_Linux_${GO_PLATFORM#linux-}.tar.gz && \ tar -xzf /tmp/leeway.tar.gz -C /tmp && \ install -m 755 /tmp/leeway /usr/local/bin/ && \ - rm /tmp/leeway.tar.gz + rm /tmp/leeway.tar.gz && \ + apt-get clean && rm -rf /var/lib/apt/lists/* diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 525e6386..b38d759a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,10 +4,32 @@ "context": "..", "dockerfile": "Dockerfile" }, + "features": { + "ghcr.io/devcontainers/features/node:1": { + "version": "lts", + "nodeGypDependencies": true, + "yarn": true + }, + "ghcr.io/devcontainers/features/go:1": { + "version": "1.24.0" + }, + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": false, + "configureZshAsDefaultShell": false, + "username": "root", + "upgradePackages": true + }, + "ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {}, + "ghcr.io/devcontainers-contrib/features/jq-apt-get:1": {}, + "ghcr.io/devcontainers-contrib/features/shfmt:1": { + "version": "3.10.0" + } + }, "runArgs": [ "--privileged", "--security-opt=seccomp=unconfined", "--network=host" ], - "containerUser": "root" + "containerUser": "root", + "postCreateCommand": "go install -v github.com/uudashr/gopkgs/cmd/gopkgs@v2 && go install -v github.com/ramya-rao-a/go-outline@latest && go install -v github.com/cweill/gotests/gotests@latest && go install -v github.com/fatih/gomodifytags@latest && go install -v github.com/josharian/impl@latest && go install -v github.com/haya14busa/goplay/cmd/goplay@latest && go install -v github.com/go-delve/delve/cmd/dlv@latest && go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest && go install -v golang.org/x/tools/gopls@latest && go install -v honnef.co/go/tools/cmd/staticcheck@latest" } From 59a982eadd2971f84f8a1b68ee5ffc2589348a0c Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Tue, 1 Apr 2025 08:09:15 +0000 Subject: [PATCH 3/7] Move Leeway installation to devcontainer.json --- .devcontainer/Dockerfile | 11 ----------- .devcontainer/devcontainer.json | 7 ++----- 2 files changed, 2 insertions(+), 16 deletions(-) delete mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index a66c43bf..00000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM ubuntu:jammy - -# Install latest Leeway release -ENV GO_PLATFORM=linux-amd64 -RUN apt-get update && apt-get install -y curl && \ - LATEST_LEEWAY_VERSION=$(curl -s https://api.github.com/repos/gitpod-io/leeway/releases/latest | grep '"tag_name"' | sed 's/.*"tag_name": "v\([^"]*\)".*/\1/') && \ - curl -L -o /tmp/leeway.tar.gz https://github.com/gitpod-io/leeway/releases/download/v${LATEST_LEEWAY_VERSION}/leeway_Linux_${GO_PLATFORM#linux-}.tar.gz && \ - tar -xzf /tmp/leeway.tar.gz -C /tmp && \ - install -m 755 /tmp/leeway /usr/local/bin/ && \ - rm /tmp/leeway.tar.gz && \ - apt-get clean && rm -rf /var/lib/apt/lists/* diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b38d759a..93ec6873 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,9 +1,5 @@ { "name": "leeway", - "build": { - "context": "..", - "dockerfile": "Dockerfile" - }, "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts", @@ -31,5 +27,6 @@ "--network=host" ], "containerUser": "root", - "postCreateCommand": "go install -v github.com/uudashr/gopkgs/cmd/gopkgs@v2 && go install -v github.com/ramya-rao-a/go-outline@latest && go install -v github.com/cweill/gotests/gotests@latest && go install -v github.com/fatih/gomodifytags@latest && go install -v github.com/josharian/impl@latest && go install -v github.com/haya14busa/goplay/cmd/goplay@latest && go install -v github.com/go-delve/delve/cmd/dlv@latest && go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest && go install -v golang.org/x/tools/gopls@latest && go install -v honnef.co/go/tools/cmd/staticcheck@latest" + "postCreateCommand": "go install -v github.com/uudashr/gopkgs/cmd/gopkgs@v2 && go install -v github.com/ramya-rao-a/go-outline@latest && go install -v github.com/cweill/gotests/gotests@latest && go install -v github.com/fatih/gomodifytags@latest && go install -v github.com/josharian/impl@latest && go install -v github.com/haya14busa/goplay/cmd/goplay@latest && go install -v github.com/go-delve/delve/cmd/dlv@latest && go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest && go install -v golang.org/x/tools/gopls@latest && go install -v honnef.co/go/tools/cmd/staticcheck@latest", + "postStartCommand": "LATEST_LEEWAY_VERSION=$(curl -s https://api.github.com/repos/gitpod-io/leeway/releases/latest | grep '\"tag_name\"' | sed 's/.*\"tag_name\": \"v\\([^\"]*\\)\".*/\\1/') && curl -L -o /tmp/leeway.tar.gz https://github.com/gitpod-io/leeway/releases/download/v${LATEST_LEEWAY_VERSION}/leeway_Linux_amd64.tar.gz && tar -xzf /tmp/leeway.tar.gz -C /tmp && sudo install -m 755 /tmp/leeway /usr/local/bin/ && rm /tmp/leeway.tar.gz" } From 8f36db042bbd02a130639aa0fca138f29238c52b Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Tue, 1 Apr 2025 08:21:04 +0000 Subject: [PATCH 4/7] Add image to devcontainer.json --- .devcontainer/devcontainer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 93ec6873..2ee9b3a2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,5 +1,6 @@ { "name": "leeway", + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "features": { "ghcr.io/devcontainers/features/node:1": { "version": "lts", From 122f52d07edf4e87705a4ebf2d07e3135a364ba2 Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Tue, 1 Apr 2025 08:31:01 +0000 Subject: [PATCH 5/7] Fix jq and curl in devcontainer --- .devcontainer/devcontainer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2ee9b3a2..2c7f0e1d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -14,10 +14,9 @@ "installZsh": false, "configureZshAsDefaultShell": false, "username": "root", - "upgradePackages": true + "upgradePackages": true, + "additionalPackages": "jq curl" }, - "ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {}, - "ghcr.io/devcontainers-contrib/features/jq-apt-get:1": {}, "ghcr.io/devcontainers-contrib/features/shfmt:1": { "version": "3.10.0" } From 8b88ea4cee8cac320471c5510163cf1a51d6f567 Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Tue, 1 Apr 2025 08:57:01 +0000 Subject: [PATCH 6/7] Tidy up devcontainer --- .devcontainer/devcontainer.json | 21 +++------------------ .devcontainer/install-leeway.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 18 deletions(-) create mode 100755 .devcontainer/install-leeway.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2c7f0e1d..1362fdeb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,30 +3,15 @@ "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "features": { "ghcr.io/devcontainers/features/node:1": { - "version": "lts", - "nodeGypDependencies": true, - "yarn": true + "version": "lts" }, "ghcr.io/devcontainers/features/go:1": { "version": "1.24.0" }, - "ghcr.io/devcontainers/features/common-utils:2": { - "installZsh": false, - "configureZshAsDefaultShell": false, - "username": "root", - "upgradePackages": true, - "additionalPackages": "jq curl" - }, + "ghcr.io/devcontainers/features/common-utils:2": {}, "ghcr.io/devcontainers-contrib/features/shfmt:1": { "version": "3.10.0" } }, - "runArgs": [ - "--privileged", - "--security-opt=seccomp=unconfined", - "--network=host" - ], - "containerUser": "root", - "postCreateCommand": "go install -v github.com/uudashr/gopkgs/cmd/gopkgs@v2 && go install -v github.com/ramya-rao-a/go-outline@latest && go install -v github.com/cweill/gotests/gotests@latest && go install -v github.com/fatih/gomodifytags@latest && go install -v github.com/josharian/impl@latest && go install -v github.com/haya14busa/goplay/cmd/goplay@latest && go install -v github.com/go-delve/delve/cmd/dlv@latest && go install -v github.com/golangci/golangci-lint/cmd/golangci-lint@latest && go install -v golang.org/x/tools/gopls@latest && go install -v honnef.co/go/tools/cmd/staticcheck@latest", - "postStartCommand": "LATEST_LEEWAY_VERSION=$(curl -s https://api.github.com/repos/gitpod-io/leeway/releases/latest | grep '\"tag_name\"' | sed 's/.*\"tag_name\": \"v\\([^\"]*\\)\".*/\\1/') && curl -L -o /tmp/leeway.tar.gz https://github.com/gitpod-io/leeway/releases/download/v${LATEST_LEEWAY_VERSION}/leeway_Linux_amd64.tar.gz && tar -xzf /tmp/leeway.tar.gz -C /tmp && sudo install -m 755 /tmp/leeway /usr/local/bin/ && rm /tmp/leeway.tar.gz" + "postStartCommand": "./.devcontainer/install-leeway.sh" } diff --git a/.devcontainer/install-leeway.sh b/.devcontainer/install-leeway.sh new file mode 100755 index 00000000..537763ac --- /dev/null +++ b/.devcontainer/install-leeway.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# This script downloads and installs the latest version of leeway + +set -euo pipefail + +# Get the latest leeway version from GitHub API +LATEST_LEEWAY_VERSION=$(curl -s https://api.github.com/repos/gitpod-io/leeway/releases/latest | jq -r '.tag_name' | sed 's/^v//') + +# Ensure we got a valid version +if [ -z "$LATEST_LEEWAY_VERSION" ]; then + echo "Error: Could not determine latest leeway version" >&2 + exit 1 +fi + +echo "Installing leeway version: $LATEST_LEEWAY_VERSION" + +# Download the latest leeway release +curl -L -o /tmp/leeway.tar.gz "https://github.com/gitpod-io/leeway/releases/download/v${LATEST_LEEWAY_VERSION}/leeway_Linux_x86_64.tar.gz" + +# Extract the tarball +tar -xzf /tmp/leeway.tar.gz -C /tmp + +# Install leeway to /usr/local/bin +sudo install -m 755 /tmp/leeway /usr/local/bin/ + +# Clean up temporary files +rm /tmp/leeway.tar.gz From d3d7dc6a16f27aa4bec013a3d3eaeb1e78ce1201 Mon Sep 17 00:00:00 2001 From: "Cornelius A. Ludmann" Date: Tue, 1 Apr 2025 09:04:44 +0000 Subject: [PATCH 7/7] Fix leeway installations script --- .devcontainer/install-leeway.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/install-leeway.sh b/.devcontainer/install-leeway.sh index 537763ac..802f8b07 100755 --- a/.devcontainer/install-leeway.sh +++ b/.devcontainer/install-leeway.sh @@ -24,4 +24,4 @@ tar -xzf /tmp/leeway.tar.gz -C /tmp sudo install -m 755 /tmp/leeway /usr/local/bin/ # Clean up temporary files -rm /tmp/leeway.tar.gz +rm /tmp/leeway.tar.gz /tmp/leeway