Skip to content

Commit 90e16a8

Browse files
author
Ganesh Jangir
authored
feat(devcontainer): add Alpine dev container configuration (#1217)
1 parent 106c59a commit 90e16a8

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
3+
{
4+
"name": "Rust (Alpine)",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/base:alpine", // more images at // more images at https://hub.docker.com/r/microsoft/devcontainers-base
7+
8+
// Allow access to host machine
9+
"runArgs": ["--network=host"],
10+
11+
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
12+
"mounts": [
13+
{
14+
"source": "devcontainer-cargo-cache-alpine-${devcontainerId}",
15+
"target": "/usr/local/cargo",
16+
"type": "volume"
17+
}
18+
],
19+
20+
"onCreateCommand": "sudo apk add --no-cache build-base rust cargo cargo-zsh-completion rust-src rustfmt cbindgen patchelf cmake",
21+
22+
"customizations": {
23+
"vscode": {
24+
"extensions": [
25+
"rust-lang.rust-analyzer",
26+
"vadimcn.vscode-lldb",
27+
"tamasfe.even-better-toml"
28+
]
29+
}
30+
}
31+
}

.devcontainer/devcontainer.json renamed to .devcontainer/ubuntu/devcontainer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
33
{
4-
"name": "Rust",
4+
"name": "Rust (Ubuntu)",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
6+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", // more images at https://hub.docker.com/r/microsoft/devcontainers-base
77

88
// Allow access to host machine
99
"runArgs": ["--network=host"],
@@ -25,14 +25,15 @@
2525
},
2626

2727
// Use 'postCreateCommand' to run commands after the container is created.
28-
"postCreateCommand": "cargo install cbindgen",
28+
"postCreateCommand": "sudo apt-get update && sudo apt-get install -y patchelf && cargo install cbindgen",
2929

3030
// Configure tool-specific properties.
3131
"customizations": {
3232
"vscode": {
3333
"extensions": [
3434
"rust-lang.rust-analyzer",
35-
"vadimcn.vscode-lldb"
35+
"vadimcn.vscode-lldb",
36+
"tamasfe.even-better-toml"
3637
]
3738
}
3839
}

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,27 @@ cargo install --locked '[email protected]'
6464

6565
#### Dev Containers
6666

67+
Dev Containers allow you to use a Docker container as a full-featured development environment with VS Code.
68+
6769
##### Prerequisites
6870

6971
- Install the [Dev Containers Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) in VS Code.
72+
- Docker must be installed and running on your host machine.
73+
74+
##### Available Containers
75+
76+
We provide two Dev Container configurations:
77+
- **Ubuntu**: Full-featured development environment with all dependencies installed
78+
- **Alpine**: Lightweight alternative with minimal dependencies
7079

7180
##### Steps
7281

7382
1. Open a local VS Code window on the cloned repository.
7483
2. Open the command palette (`Ctrl+Shift+P` or `Cmd+Shift+P` on macOS) and select **"Dev Containers: Reopen in Container"**.
75-
3. Choose the **Rust Container**.
76-
4. VS Code will open a new window connected to the selected container.
84+
3. Choose either **Ubuntu** or **Alpine** configuration when prompted.
85+
4. VS Code will build and connect to the selected container environment.
86+
87+
The container includes all necessary dependencies for building and testing `libdatadog`.
7788

7889
#### Docker container
7990
A dockerfile is provided to run tests in a Ubuntu linux environment. This is particularly useful for running and debugging linux-only tests on macOS.

0 commit comments

Comments
 (0)