From 1d92d8c90c468c86426c144433440966f02a9f44 Mon Sep 17 00:00:00 2001 From: krissetto Date: Fri, 2 Feb 2024 13:00:06 +0000 Subject: [PATCH] initial devcontainer config + updated docs for usage info Signed-off-by: krissetto --- .devcontainer/devcontainer.json | 41 +++++++++++++++++++++++++++++++++ .github/dependabot.yml | 4 ++++ CONTRIBUTING.md | 26 +++++++++++++++++++++ README.md | 12 ++++++++-- 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000000..a3ddb837032e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,41 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/go +{ + "name": "cli - devcontainer", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/go:1-1.21-bullseye", + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": true, + "configureZshAsDefaultShell": true, + "installOhMyZsh": true, + "installOhMyZshConfig": true, + "upgradePackages": true, + "username": "devcontainer", + "userUid": "1001", + "userGid": "1001" + }, + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "moby": true, + "version": "latest", + "dockerDashComposeVersion": "v2" + }, + "ghcr.io/devcontainers/features/git:1": { + "ppa": true, + "version": "latest" + } + }, + // Use 'postStartCommand' to run commands after the container is started. + "postStartCommand": "cd /workspaces/cli/ && ln -sf vendor.mod go.mod && ln -sf vendor.sum go.sum && go mod tidy", + // Configure tool-specific properties. + "customizations": { + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": {}, + "extensions": [ + "bierner.markdown-mermaid" + ] + } + } +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 53a17bae892a..d2ab07dd60f6 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,3 +7,7 @@ updates: labels: - "area/testing" - "status/2-code-review" + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index faeb3fc506d3..a205db77a3d4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,12 +7,38 @@ start participating. ## Topics +* [Development environment](#development-environment) * [Reporting Security Issues](#reporting-security-issues) * [Design and Cleanup Proposals](#design-and-cleanup-proposals) * [Reporting Issues](#reporting-other-issues) * [Quick Contribution Tips and Guidelines](#quick-contribution-tips-and-guidelines) * [Community Guidelines](#docker-community-guidelines) +## Development environment + +The only requirements for setting up a local development environment are: + +- [`go`](https://go.dev/dl/) -> latest version is fine, we use `//go:build go1.xx` directives in individual files to build those using a specific version of the go language/compiler; +- [`docker`](https://www.docker.com) -> latest version is also fine; +- `make` (on MacOS, install the developer command line tools with `xcode-select --install`) +- IDE of your choice ([`VSCode`](https://code.visualstudio.com/download), [`Jetbrains GoLand`](https://www.jetbrains.com/go/), etc.) + +### Go modules + +Currently the project is not setup as a standard "go modules" project to avoid breaking dependant projects. To develop the project as if it were a go module project, you should symlink the `vendor.mod/sum` files to `go.mod/sum`, the following command should do the trick: + +`ln -s vendor.mod go.mod && ln -s vendor.sum go.sum` + +This step is unnecessary if using the devcontainers approach seen below, as it's already configured to create the symlinks for development. + +### Using a devcontainer + +This project also comes with an included `.devcontainer/` directory and a `devcontainer.json` file that can be used with `VSCode` or `GoLand` to quickly setup a development container, with all the basic required development dependencies already included. + +Using VSCode, all that's required is installing the [`Dev Containers` extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containersCheck), and it should auto-detect the `devcontainer.json` file and give you the option to start the container. + +For other IDEs, please check the relevant documentation of your editor for instructions on how to use devcontainers + ## Reporting security issues The Docker maintainers take security seriously. If you discover a security diff --git a/README.md b/README.md index 232117eb4f79..184891dcbce1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,11 @@ This repository is the home of the Docker CLI. ## Development -`docker/cli` is developed using Docker. +`docker/cli` is developed using Docker. + +See the [`CONTRIBUTING.md`](./CONTRIBUTING.md) doc for more information on seting up a development environment. + +### Some useful commands Build CLI from source: @@ -58,7 +62,11 @@ make help ### In-container development environment -Start an interactive development environment: +#### Using a `devcontainer`. + +See [using a devcontainer](./CONTRIBUTING.md#using-a-devcontainer) for more details + +#### Start an interactive development environment shell: ```shell make -f docker.Makefile shell