Skip to content

Commit

Permalink
Add .devcontainer (#36422)
Browse files Browse the repository at this point in the history
Adds .devcontainer, a standard way to describe development containers. See the VSCode documentation and the .devcontainer spec for more info. You can use devcontainers with other IDEs like intellij, see supported tools for more info. If you haven't used dev containers before, they're simple to get started. If this file is present in your container VSCode will ask you on opening the project whether you want to use the container. If so, it will build the container and you can go from there.

This file can be ignored by those who wish to develop on their native system, but is highly useful for those (like myself) who occasionally:

Need to develop linux specific things that depend on linux kernel features
Want to not have to setup tools on a new box
Want to share the burden of setting up a dev stack.
This devcontainer is somewhat barebones for beats dev, but does include:

golang, Mage, node (for synthetics), docker (using host docker), ZSH as default shell, with other helpful utils
The goal of this commit is to be minimal, and not include every useful thing for beats dev, follow-up PRs could include more specific functionality.
  • Loading branch information
andrewvc committed Aug 28, 2023
1 parent 5fa3a2c commit a182baf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .ci/bump-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ targets:
content: ':go-version: {{ source "latestGoVersion" }}'
file: libbeat/docs/version.asciidoc
matchpattern: ':go-version: \d+.\d+.\d+'
update-devcontainer:
name: "Update .devcontainer/devcontainer.json"
sourceid: gomod
scmid: githubConfig
kind: file
spec:
content: 'go:1-{{ source "gomod" }}'
file: ./.devcontainer/devcontainer.json
matchpattern: 'go:1-\d+.\d+'
update-auditbeat-dockerfile:
name: "Update Auditbeat Dockerfile"
sourceid: latestGoVersion
Expand Down
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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
// If you're wondering how to get SSH working for git pushes, make sure to ssh-add ~/.ssh/<YOURPRIVATEKEY> on your host system
// to make sure the ssh agent has your key
{
"name": "Beats Development Container",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/go:1-1.20-bullseye",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// Mage is installed this way, and not via the feature plugin because that plugin was
// broken for me, and mage install is simple enough
"postCreateCommand": "cd /opt/; sudo mkdir mage; sudo chown $USER:$(id -g) mage; git clone --depth=1 https://github.com/magefile/mage && cd mage && go run bootstrap.go"

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

0 comments on commit a182baf

Please sign in to comment.