Skip to content

Commit 85a02f1

Browse files
authored
Add a devcontainer config (#1432)
GitHub supports [dev containers][dc] to describe reproducible development environments (e.g. for use from VS code). This change introduces a devcontainer.json and Dockerfile to support container-based development. This setup configures docker-in-docker so that docker and k3d can be run inside the dev container. This base configuration can be amended with per-user personalizations via a [dotfiles][df] repo. For example: github.com/olix0r/dotfiles. [dc]: https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/configuring-codespaces-for-your-project [df]: https://docs.github.com/en/codespaces/customizing-your-codespace/personalizing-codespaces-for-your-account Signed-off-by: Oliver Gould <[email protected]>
1 parent 809d4d3 commit 85a02f1

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM docker.io/rust:1.56.1-bullseye
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
RUN apt update && apt upgrade -y
5+
RUN apt install -y \
6+
clang \
7+
cmake \
8+
golang \
9+
lldb \
10+
lsb-release \
11+
sudo \
12+
time
13+
14+
ARG USER=code
15+
ARG USER_UID=1000
16+
ARG USER_GID=1000
17+
RUN groupadd --gid=$USER_GID $USER \
18+
&& useradd --uid=$USER_UID --gid=$USER_GID -m $USER \
19+
&& echo "$USER ALL=(root) NOPASSWD:ALL" >/etc/sudoers.d/$USER \
20+
&& chmod 0440 /etc/sudoers.d/$USER
21+
22+
# Install a Docker client that uses the host's Docker daemon
23+
ARG USE_MOBY=false
24+
ENV DOCKER_BUILDKIT=1
25+
RUN curl --proto '=https' --tlsv1.3 -vsSfL https://raw.githubusercontent.com/microsoft/vscode-dev-containers/main/script-library/docker-debian.sh \
26+
| bash -s -- true /var/run/docker-host.sock /var/run/docker.sock "${USER}" "${USE_MOBY}" latest
27+
28+
USER $USER
29+
ENV HOME=/home/$USER
30+
RUN mkdir -p $HOME/bin
31+
ENV PATH=$HOME/bin:$PATH
32+
33+
RUN curl --proto '=https' --tlsv1.3 -vsSfLo $HOME/kubectl "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
34+
&& chmod 755 $HOME/kubectl
35+
RUN curl --proto '=https' --tlsv1.3 -vsSfL https://raw.githubusercontent.com/rancher/k3d/main/install.sh \
36+
| USE_SUDO=false K3D_INSTALL_DIR=$HOME/bin bash
37+
38+
RUN rustup component add clippy rustfmt
39+
RUN mkdir /tmp/cargo-deny && cd /tmp/cargo-deny && \
40+
curl --proto '=https' --tlsv1.3 -vsSfL https://github.com/EmbarkStudios/cargo-deny/releases/download/0.11.0/cargo-deny-0.11.0-x86_64-unknown-linux-musl.tar.gz \
41+
| tar zxf - \
42+
&& mv cargo-deny-0.11.0-x86_64-unknown-linux-musl/cargo-deny $HOME/bin \
43+
&& cd .. && rm -rf /tmp/cargo-deny
44+
45+
RUN curl --proto '=https' --tlsv1.3 -vsSfL https://run.linkerd.io/install-edge | sh \
46+
&& ln -s $(readlink ~/.linkerd2/bin/linkerd) ~/bin/linkerd
47+
48+
ENTRYPOINT ["/usr/local/share/docker-init.sh"]
49+
CMD ["sleep", "infinity"]

.devcontainer/devcontainer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "linkerd2-proxy",
3+
"image": "ghcr.io/linkerd/dev-proxy:v3",
4+
//"dockerFile": "./Dockerfile",
5+
"extensions": [
6+
"DavidAnson.vscode-markdownlint",
7+
"matklad.rust-analyzer",
8+
"NathanRidley.autotrim",
9+
"samverschueren.final-newline",
10+
"streetsidesoftware.code-spell-checker",
11+
"tamasfe.even-better-toml",
12+
"vadimcn.vscode-lldb",
13+
"zxh404.vscode-proto3"
14+
],
15+
// Support docker + debugger
16+
"runArgs": [
17+
"--init",
18+
// Use the host network so we can access k3d, etc.
19+
"--net=host",
20+
// For lldb
21+
"--cap-add=SYS_PTRACE",
22+
"--security-opt=seccomp=unconfined"
23+
],
24+
"overrideCommand": false,
25+
"remoteUser": "code",
26+
"mounts": [
27+
"source=/var/run/docker.sock,target=/var/run/docker-host.sock,type=bind"
28+
]
29+
}

0 commit comments

Comments
 (0)