Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic devcontainer config #4845

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions .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
{
Comment on lines +1 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON doesn't allow comments 🤔 should this have a jsonc file-extension ? (is that the official extension for it?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the official devcontainers spec defines the file as a JSON with Comments, but using the .json extension. I know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 that feels very "YOLO - works for us, just not for everyone else"

"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"
]
}
}
}
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Expand Up @@ -7,3 +7,7 @@ updates:
labels:
- "area/testing"
- "status/2-code-review"
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is cloning the CLI repo inside your global GOPATH. Although I guess we will move to go modules soonish?

mkdir -p $GOPATH/src/github.com/docker/
cd $GOPATH/src/github.com/docker
git clone git@github.com:docker/cli.git


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
Expand Down
12 changes: 10 additions & 2 deletions README.md
Expand Up @@ -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:

Expand Down Expand Up @@ -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
Expand Down