Skip to content

Instantly share code, notes, and snippets.

@linw1995
Created August 18, 2024 13:30
Show Gist options
  • Save linw1995/b44752cad2451c0bca8258efb196fc6a to your computer and use it in GitHub Desktop.
Save linw1995/b44752cad2451c0bca8258efb196fc6a to your computer and use it in GitHub Desktop.
An example of rust dev-container for cross compiling on remote docker.

This currently supports vector development.

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
{
"name": "Rust",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
"mounts": [
{
"source": "devcontainer-cargo-cache-${devcontainerId}",
"target": "/usr/local/cargo",
"type": "volume"
},
{
"source": "/var/run/docker.sock",
"target": "/var/run/docker.sock",
"type": "bind"
}
],
"workspaceFolder": "/workspace",
"workspaceMount": "source=devcontainer-workspace,target=/workspace,type=volume",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers-contrib/features/protoc: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.
"postCreateCommand": "sudo apt update && sudo apt install -y libsasl2-dev",
// Configure tool-specific properties.
// "customizations": {},
"remoteEnv": {
"CROSS_CONTAINER_IN_CONTAINER": "true"
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "root"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment