-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying slim dockerfile for devcontainer
- Loading branch information
Showing
10 changed files
with
172 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.devcontainer/devcontainer.json → ...tainer/docker-in-docker/devcontainer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. | ||
{ | ||
"build": { | ||
"dockerfile": "../slim.Dockerfile", | ||
"context": "../..", | ||
"args": { | ||
"CLAB_VERSION": "${localEnv:CLAB_VERSION}" | ||
} | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": { | ||
"version": "26.1.4", | ||
"dockerDashComposeVersion": "none", | ||
"moby": "false" | ||
}, | ||
// Add sshd to support gh cli codespace cp. | ||
"ghcr.io/devcontainers/features/sshd:1": { | ||
"version": "latest" | ||
} | ||
}, | ||
"remoteUser": "vscode", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-azuretools.vscode-docker", | ||
// Python. | ||
"ms-python.python", | ||
// Errors and highlighters. | ||
"mechatroner.rainbow-csv", | ||
"redhat.vscode-yaml", | ||
// markdown | ||
"yzhang.markdown-all-in-one", | ||
"davidanson.vscode-markdownlint" | ||
] | ||
} | ||
}, | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/${containerWorkspaceFolder},type=bind", | ||
"workspaceFolder": "/clab" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.devcontainer/docker-outside-of-docker_slim/devcontainer.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. | ||
{ | ||
"build": { | ||
"dockerfile": "../slim.Dockerfile", | ||
"context": "../..", | ||
"args": { | ||
"CLAB_VERSION": "${localEnv:CLAB_VERSION}" | ||
} | ||
}, | ||
"runArgs": [ | ||
"--network=host", | ||
"--pid=host", | ||
"--privileged" | ||
], | ||
"mounts": [ | ||
"type=bind,src=/run/netns,dst=/run/netns", | ||
"type=bind,src=/var/lib/docker,dst=/var/lib/docker" | ||
], | ||
"features": { | ||
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": { | ||
"version": "26.1.4", | ||
"dockerDashComposeVersion": "none", | ||
"moby": "false" | ||
}, | ||
// Add sshd to support gh cli codespaces cp. | ||
"ghcr.io/devcontainers/features/sshd:1": { | ||
"version": "latest" | ||
} | ||
}, | ||
"remoteUser": "vscode", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-azuretools.vscode-docker", | ||
// Python. | ||
"ms-python.python", | ||
// Errors and highlighters. | ||
"mechatroner.rainbow-csv", | ||
"redhat.vscode-yaml", | ||
// markdown | ||
"yzhang.markdown-all-in-one", | ||
"davidanson.vscode-markdownlint" | ||
] | ||
} | ||
}, | ||
"workspaceFolder": "${localWorkspaceFolder}", | ||
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
FROM mcr.microsoft.com/devcontainers/python:3.11-bookworm | ||
|
||
ARG CLAB_VERSION | ||
|
||
# Add the netdevops repository | ||
RUN echo "deb [trusted=yes] https://netdevops.fury.site/apt/ /" | \ | ||
tee -a /etc/apt/sources.list.d/netdevops.list | ||
|
||
# Install necessary packages, including curl | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
direnv \ | ||
btop \ | ||
iputils-ping \ | ||
tcpdump \ | ||
iproute2 \ | ||
qemu-kvm \ | ||
dnsutils \ | ||
telnet \ | ||
curl | ||
|
||
# Install Containerlab | ||
RUN bash -c "$(curl -sL https://get.containerlab.dev)" -- -v ${CLAB_VERSION} | ||
|
||
# Install GitHub CLI directly from the latest release | ||
RUN bash -c 'ARCH=$(uname -m | sed "s/x86_64/amd64/" | sed "s/aarch64/arm64/") && \ | ||
VERSION=$(curl -s https://api.github.com/repos/cli/cli/releases/latest | \ | ||
grep -oP "\"tag_name\": \"\K[^\"]+") && \ | ||
CLEAN_VERSION=${VERSION#v} && \ | ||
DOWNLOAD_URL="https://github.com/cli/cli/releases/download/${VERSION}/gh_${CLEAN_VERSION}_linux_${ARCH}.tar.gz" && \ | ||
curl -L "$DOWNLOAD_URL" | tar xz -C /tmp && \ | ||
mv /tmp/gh_${CLEAN_VERSION}_linux_${ARCH}/bin/gh /usr/local/bin/ && \ | ||
chmod +x /usr/local/bin/gh && \ | ||
rm -rf /tmp/gh_${CLEAN_VERSION}_linux_${ARCH}' | ||
|
||
# Add empty docker config files to avoid clab warnings for root user | ||
RUN mkdir -p /root/.docker && echo "{}" > /root/.docker/config.json | ||
|
||
# Maintain SSH_AUTH_SOCK env var when using sudo | ||
RUN mkdir -p /etc/sudoers.d && echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/ssh_auth_sock | ||
|
||
# Switch to the vscode user provided by the base image | ||
USER vscode | ||
|
||
# Copy dclab script used to run the local containerlab build after `make build` | ||
COPY ./.devcontainer/dclab /usr/local/bin/dclab | ||
|
||
# Create SSH key for vscode user to enable passwordless SSH to devices | ||
RUN ssh-keygen -t ecdsa -b 256 -N "" -f ~/.ssh/id_ecdsa | ||
|
||
# Add empty docker config files to avoid clab warnings for vscode user | ||
RUN mkdir -p /home/vscode/.docker && echo "{}" > /home/vscode/.docker/config.json | ||
|
||
# Setup Zsh and plugins | ||
COPY ./.devcontainer/zsh/.zshrc /home/vscode/.zshrc | ||
COPY ./.devcontainer/zsh/.p10k.zsh /home/vscode/.p10k.zsh | ||
COPY ./.devcontainer/zsh/install-zsh-plugins.sh /tmp/install-zsh-plugins.sh | ||
RUN bash -c "/tmp/install-zsh-plugins.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
gnmic completion zsh > "/home/vscode/.oh-my-zsh/custom/plugins/zsh-autocomplete/Completions/_gnmic" | ||
# generate gnoic completions | ||
gnoic completion zsh > "/home/vscode/.oh-my-zsh/custom/plugins/zsh-autocomplete/Completions/_gnoic" | ||
# generate gh | ||
gh completion -s zsh > "/home/vscode/.oh-my-zsh/custom/plugins/zsh-autocomplete/Completions/_gh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters