diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 71430fa9b..b324f3097 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -7,6 +7,12 @@ RUN apt-get install --no-install-recommends -y build-essential file nano && \ apt-get autoremove --yes && \ rm -rf /var/lib/apt/lists/* +RUN wget https://dl.google.com/go/go1.16.10.linux-amd64.tar.gz && \ + tar -xvf go1.16.10.linux-amd64.tar.gz && \ + mv go /usr/local + +RUN GOROOT=/usr/local/go /usr/local/go/bin/go install golang.org/x/tools/gopls@latest 2>&1 + ADD https://raw.githubusercontent.com/dokku/dokku/master/tests/dhparam.pem /mnt/dokku/etc/nginx/dhparam.pem COPY .devcontainer/bin/ /usr/local/bin/ @@ -15,5 +21,6 @@ RUN make ci-dependencies COPY . . -ENV DOKKU_HOSTNAME=dokku.me +ENV DOKKU_HOSTNAME=dokku.me GOROOT=/usr/local/go PATH=/usr/local/go/bin:$PATH PLUGIN_MAKE_TARGET=build + LABEL org.label-schema.schema-version=1.0 org.label-schema.vendor=dokku com.dokku.devcontainer=true diff --git a/.devcontainer/bin/copy-plugin b/.devcontainer/bin/copy-plugin index 9bfe505bf..a17348db1 100755 --- a/.devcontainer/bin/copy-plugin +++ b/.devcontainer/bin/copy-plugin @@ -3,7 +3,7 @@ main() { declare PLUGIN_NAME="$1" - make go-build-plugin copyplugin PLUGIN_NAME=$PLUGIN_NAME + make go-build-plugin copyplugin PLUGIN_NAME=$PLUGIN_NAME PLUGIN_MAKE_TARGET=build } main "$@" diff --git a/.devcontainer/bin/go-mod-downloadall b/.devcontainer/bin/go-mod-downloadall new file mode 100755 index 000000000..b52190798 --- /dev/null +++ b/.devcontainer/bin/go-mod-downloadall @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -x + +main() { + find plugins/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | while read plugin; do + if [[ ! -f "plugins/$plugin/go.mod" ]]; then + continue + fi + + pushd "plugins/$plugin" >/dev/null || return 1 + echo "====> Cloning all modules $plugin" + go list -m -f '{{define "M"}}git clone https://{{.Path}}.git /root/go/src/{{.Path}} || true && echo {{.Version}}{{end}}{{if not .Main}}{{if not .Replace}}{{template "M" .}}{{end}}{{end}}' all >tmp-file + bash tmp-file + rm tmp-file + + go list -m -f '{{define "M"}}git clone https://{{.Path}}.git /usr/local/go/src/{{.Path}} || true && echo {{.Version}}{{end}}{{if not .Main}}{{if not .Replace}}{{template "M" .}}{{end}}{{end}}' all >tmp-file + bash tmp-file + rm tmp-file + popd >/dev/null || return 1 + done +} + +main "$@" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7af15371b..db695e264 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,12 +7,19 @@ "DOKKU_HOST_ROOT": "${localWorkspaceFolder}/tmp/data/home/dokku", "GO_ROOT_MOUNT": "${localWorkspaceFolder}:/go/src/github.com/dokku/dokku" }, + "extensions": [ + "golang.go", + "mads-hartmann.bash-ide-vscode", + "ms-vscode.makefile-tools" + ], "initializeCommand": ["mkdir", "-p", "tmp/data"], "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind", "source=${localWorkspaceFolder}/tmp/data/,target=/mnt/dokku/,type=bind" ], "overrideCommand": false, - "postCreateCommand": ["make", "setup-deploy-tests"], - "runArgs": ["--init"] + "postCreateCommand": "make setup-deploy-tests && go-mod-downloadall", + "runArgs": ["--init"], + "workspaceFolder": "/root/go/src/github.com/dokku/dokku", + "workspaceMount": "type=bind,source=${localWorkspaceFolder},target=/root/go/src/github.com/dokku/dokku,consistency=cached" } diff --git a/.gitignore b/.gitignore index f7be175a6..deb157886 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .DS_Store .ruby-version .idea/ +.vscode/ .vagrant build/ data/