Skip to content

Commit

Permalink
initial devcontainer config + updated docs for usage info
Browse files Browse the repository at this point in the history
Signed-off-by: krissetto <chrisjpetito@gmail.com>
  • Loading branch information
krissetto committed Feb 2, 2024
1 parent 843951e commit 1d92d8c
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 2 deletions.
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
{
"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

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

0 comments on commit 1d92d8c

Please sign in to comment.