Skip to content

Commit

Permalink
feat: devcontainer (#2156)
Browse files Browse the repository at this point in the history
# Description

This PR presents a complete devcontainer environment for building with
the CoW Protocol services repository.

# Changes

- [x] Build using the latest standard `rust` devcontainer
- [x] Enhance the `rust` devcontainer with `gdb`, `valgrind`, and
`heaptrack`
- [x] Installs both `stable` and `nightly` toolchains, automatically
configuring rust-analyzer to use `nightly` for `rustfmt`
- [x] Includes `docker`, `postgresql-client` and `node` for development
- [x] Configures the `zsh` shell
- [x] Adjusts docker settings to enable trace capabilities for profiling
development

## How to test

1. Open in VS Code and take it for a spin

**Caution**: This can take a while to build the container environment on
first start.
  • Loading branch information
mfw78 authored Dec 15, 2023
1 parent c263173 commit ac0c655
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mcr.microsoft.com/devcontainers/base:bullseye

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
&& apt-get purge -y imagemagick imagemagick-6-common

# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends gdb valgrind heaptrack
59 changes: 59 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"build": {
"dockerfile": "./Dockerfile",
"context": "."
},
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"configureZshAsDefaultShell": true,
"installOhMyZsh": true,
"installOhMyZshConfig": true,
"upgradePackages": true,
"username": "automatic",
"userUid": "automatic",
"userGid": "automatic"
},
"ghcr.io/devcontainers/features/rust:1": {},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/nlordell/features/foundry": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"dockerDashComposeVersion": "v2"
},
"ghcr.io/robbert229/devcontainer-features/postgresql-client:1": {},
"ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {
"plugins": "npm git rust docker docker-compose git-prompt postgres",
"omzPlugins": "https://github.com/zsh-users/zsh-autosuggestions",
"username": "vscode"
}
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],

"customizations": {
"vscode": {
"settings": {
"rust-analyzer.rustfmt.extraArgs": [
"+nightly"
]
},
"extensions": [
"rust-lang.rust-analyzer",
"serayuzgur.crates"
]
}
},

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

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",
"postCreateCommand": "rustup toolchain install nightly && cargo install flamegraph",

// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}

0 comments on commit ac0c655

Please sign in to comment.