Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
b48fca6
add arm to base container
ankudinov Aug 18, 2025
565e5f2
add 1.7
ankudinov Aug 18, 2025
e794f3e
update evpn lab with 1.7
ankudinov Aug 18, 2025
35adff8
fix ceos version and ardl
ankudinov Aug 18, 2025
4baff62
add default token
ankudinov Aug 18, 2025
6bdcef9
move make start
ankudinov Aug 19, 2025
dc02cd3
add coder pre-build
ankudinov Aug 19, 2025
8706964
add coder labs
ankudinov Aug 19, 2025
533fd36
add temp fixes to coder lab archive
ankudinov Aug 19, 2025
5a027dd
fix path
ankudinov Aug 19, 2025
330aa7e
add devcontainer check
ankudinov Aug 19, 2025
059f4cd
change workspace
ankudinov Aug 20, 2025
dac78d7
change wsf for coder
ankudinov Aug 20, 2025
10bd228
fix onCreate for coder
ankudinov Aug 20, 2025
44d4a3e
fix line number
ankudinov Aug 20, 2025
3d1d489
add rm for cEOS-lab images
ankudinov Aug 20, 2025
def02c7
fix cp
ankudinov Aug 20, 2025
6492ee8
fix cp again
ankudinov Aug 20, 2025
b7bd67c
and again fix cp =)
ankudinov Aug 20, 2025
6f728b9
add coder extensions to postCreate
ankudinov Aug 20, 2025
ae1c9fa
always rebuild images for testing
ankudinov Aug 21, 2025
6e4d78d
.
ankudinov Aug 21, 2025
591b708
Revert "."
ankudinov Aug 21, 2025
a499846
try CONTAINERWSF
ankudinov Aug 21, 2025
365db0b
try ${CONTAINERWSF}
ankudinov Aug 21, 2025
e4cd416
always push images
ankudinov Aug 21, 2025
63d30e5
test with dockerfile
ankudinov Aug 21, 2025
3ebee34
try again
ankudinov Aug 21, 2025
ab7e729
try 127.0.0.1
ankudinov Aug 21, 2025
39ef7cb
.
ankudinov Aug 21, 2025
9a191b1
.
ankudinov Aug 21, 2025
f925fc4
.
ankudinov Aug 21, 2025
dbf67bc
test entrypoint
ankudinov Aug 21, 2025
d34dbc7
try entrypoint with WSF
ankudinov Aug 21, 2025
f923f2a
clean coder devcontainer.json
ankudinov Aug 21, 2025
226704e
simplify logic
ankudinov Aug 21, 2025
0375224
use truncate
ankudinov Aug 21, 2025
7cca810
.
ankudinov Aug 21, 2025
e4f7f0a
.
ankudinov Aug 21, 2025
41af465
add import for ceos in workspace
ankudinov Aug 21, 2025
033940f
switch back to labs/<lab> structure
ankudinov Aug 21, 2025
33975e2
fix if condition
ankudinov Aug 21, 2025
e9ed314
improve cEOS-lab image cleaning
ankudinov Aug 21, 2025
a3cc01c
.
ankudinov Aug 21, 2025
0d73c90
try to install coder under user
ankudinov Aug 21, 2025
d7bb8eb
remove comments
ankudinov Aug 21, 2025
4e67164
add clab topology labels
ankudinov Aug 21, 2025
0a4228b
switch to appPort
ankudinov Aug 22, 2025
9ca7109
add appPort
ankudinov Aug 25, 2025
6a33f78
add exec to entrypoint
ankudinov Aug 29, 2025
d7de1c4
add docker init
ankudinov Aug 29, 2025
d69e178
run code-server in background
ankudinov Aug 29, 2025
b27b734
update entrypoint
ankudinov Aug 29, 2025
3082f96
add LAB_NAME
ankudinov Aug 29, 2025
58e814f
fix lab_name block
ankudinov Aug 29, 2025
9df74d2
.
ankudinov Aug 29, 2025
7d9a86a
.
ankudinov Aug 29, 2025
9adff17
.
ankudinov Aug 29, 2025
49835bc
.
ankudinov Aug 29, 2025
4b92321
.
ankudinov Aug 29, 2025
e278b54
.
ankudinov Aug 29, 2025
2ed670f
.
ankudinov Aug 29, 2025
b5b33b6
.
ankudinov Sep 1, 2025
fd4d33d
.
ankudinov Sep 4, 2025
7a9b94d
init arlabs container
ankudinov Sep 10, 2025
d14309a
add token file logic
ankudinov Sep 10, 2025
443d1fd
update ceos lab extension settings
ankudinov Sep 16, 2025
0bf5668
fix exec command
ankudinov Sep 16, 2025
6a6f910
set workbench to readme
ankudinov Sep 16, 2025
4fb06b6
add coder global workspace settings
ankudinov Sep 16, 2025
6cf18f0
.
ankudinov Sep 18, 2025
6154190
.
ankudinov Sep 18, 2025
af114d9
test codespaces with arlabs container
ankudinov Sep 18, 2025
05f95e7
change post create
ankudinov Sep 19, 2025
d1bcd3e
.
ankudinov Sep 19, 2025
aa5e4ac
.
ankudinov Sep 19, 2025
8b4282b
.
ankudinov Sep 19, 2025
dfde4c6
try old uid
ankudinov Sep 19, 2025
8ce3ac0
.
ankudinov Sep 19, 2025
ed8c5c1
.
ankudinov Sep 19, 2025
276169e
.
ankudinov Sep 19, 2025
346ccca
bring coder back
ankudinov Sep 19, 2025
fb7436a
bring back postCreate
ankudinov Sep 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cp/copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ceos_lab_version:
type: str
help: Please select the cEOS-lab version.
when: "{{ 'lab' | _in(templates) }}"
choices: ["4.32.3M"]
choices: ["4.34.2F"]

clab_version:
type: str
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"image": "ghcr.io/${localEnv:GITHUB_REPOSITORY}/lab-base:python3.11-avd-v5.1.0-clab0.65.1-rev1.3",
// "image": "ghcr.io/${localEnv:GITHUB_REPOSITORY}/lab-base:python3.11-avd-v5.5.1-clab0.68.0-rev1.7",
"image": "ghcr.io/ankudinov/aclabs/arlabs:rev0.2",
// containerEnv set the variables applied to entire container
"containerEnv": {
"ARISTA_TOKEN": "${localEnv:ARTOKEN}",
"CEOS_LAB_VERSION": "4.32.3M",
"CEOS_LAB_VERSION": "4.34.2F",
"CV_API_TOKEN": "${localEnv:CV_API_TOKEN}",
"CONTAINERWSF": "${containerWorkspaceFolder}",
"GITHUB_REPOSITORY": "${localEnv:GITHUB_REPOSITORY}"
"GITHUB_REPOSITORY": "${localEnv:GITHUB_REPOSITORY}",
"PASSWORD": "${localEnv:CODER_PASSWORD}"
},
"secrets": {
"CV_API_TOKEN": {
Expand All @@ -28,7 +30,8 @@
"storage": "64gb"
},
"onCreateCommand": "chmod +x /cvaas-cvaas-and-avd-demo--evpn-mlag/addAliases.sh; /cvaas-cvaas-and-avd-demo--evpn-mlag/addAliases.sh",
"postCreateCommand": "postCreate.sh; make start",
// "postCreateCommand": "postCreate.sh",
"postCreateCommand": "/usr/local/bin/code-server-entrypoint",
"workspaceMount": "source=${localWorkspaceFolder}/labs/${containerWorkspaceFolder},target=/${containerWorkspaceFolder},type=bind",
"workspaceFolder": "/cvaas-cvaas-and-avd-demo--evpn-mlag",
"containerUser": "avd"
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/container_build_arlabs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Create arlabs container image

on:
push:
branches: ['**'] # branches will be filtered in the jobs
paths:
- .github/workflows/container_build_arlabs.yml
- .github/workflows/container_build_child.yml
- containers/arlabs/**
workflow_dispatch:
branches: ['**'] # branches will be filtered in the jobs
# 1 - counter to trigger build until branch is merged

jobs:
build-demo-container:
# fork - build container from any branch for testing
# parent repo - build on main branch only
if: github.repository != 'aristanetworks/acLabs' || github.ref == 'refs/heads/main'
uses: ./.github/workflows/container_build_child.yml
with:
container_name: "arlabs"
# the rev number will be updated with each run
# image_tags: "latest,rev1.0"
image_tags: "rev0.2"
2 changes: 1 addition & 1 deletion .github/workflows/container_build_child.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
- name: Pre-build dev container image 🔨
uses: devcontainers/[email protected]
# Only build and push the image if at least one of the image tags does not exist.
if: steps.check-image.outputs.exit_code != 0
# if: steps.check-image.outputs.exit_code != 0
env:
FROM_IMAGE: ${{ inputs.from_image }}
FROM_VARIANT: ${{ inputs.from_variant }}
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/container_build_coder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Create Coder container image

on:
push:
branches: ['**'] # branches will be filtered in the jobs
paths:
- .github/workflows/container_build_coder.yml
- .github/workflows/container_build_child.yml
- containers/coder/**
workflow_dispatch:
branches: ['**'] # branches will be filtered in the jobs
# 1 - counter to trigger build until branch is merged

jobs:
build-demo-container:
# fork - build container from any branch for testing
# parent repo - build on main branch only
if: github.repository != 'aristanetworks/acLabs' || github.ref == 'refs/heads/main'
uses: ./.github/workflows/container_build_child.yml
with:
container_name: "coder"
# the rev number will be updated with each run
# image_tags: "latest,rev1.0"
image_tags: "rev1.1"
4 changes: 3 additions & 1 deletion .github/workflows/container_build_parent_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ jobs:
# 1.6:
# - Add AVD 5.5.1
# - Add ContainerLab 0.68.0
container_revision: "1.6"
# 1.7:
# - add ARM support
container_revision: "1.7"
26 changes: 26 additions & 0 deletions .github/workflows/publish-pages-on-forks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,32 @@ jobs:
done
rm -rf temp_labs/

# testing lab setup for Coder image
- name: Add lab archive for coder image
run: |
mkdir site/coder_labs
mkdir temp_labs
for DEMO_DIR in labs/*
do
DEMO_NAME="${DEMO_DIR##*/}"
mkdir temp_labs/${DEMO_NAME}
mkdir temp_labs/${DEMO_NAME}/.devcontainer
mkdir temp_labs/${DEMO_NAME}/labs
cp -r .devcontainer/${DEMO_NAME}/* temp_labs/${DEMO_NAME}/.devcontainer/
echo "adding fixes to devcontainer for coder environment"
sed -e '2d;$d' temp_labs/${DEMO_NAME}/.devcontainer/devcontainer.json > devcontainer.json
truncate -s -1 devcontainer.json
printf ',\n' >> devcontainer.json
echo ' "appPort": [8080],' >> devcontainer.json
echo ' "image": "ghcr.io/ankudinov/aclabs/coder:rev1.0"' >> devcontainer.json
echo '}' >> devcontainer.json
mv devcontainer.json temp_labs/${DEMO_NAME}/.devcontainer/devcontainer.json
cat temp_labs/${DEMO_NAME}/.devcontainer/devcontainer.json
cp -r labs/${DEMO_NAME}/ temp_labs/${DEMO_NAME}/labs/
tar -czvf site/coder_labs/${DEMO_NAME}-coder.tar.gz --directory temp_labs/ ${DEMO_NAME}
done
rm -rf temp_labs/

- name: Setup Pages 📖
uses: actions/configure-pages@v5

Expand Down
34 changes: 34 additions & 0 deletions containers/arlabs/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG FROM_IMAGE
ARG FROM_VARIANT

FROM ${FROM_IMAGE}:${FROM_VARIANT}

ARG USERNAME

USER root

ENV NEW_UID="1009"
ENV NEW_GID="1009"
ENV OLD_GID="1000"
RUN sed -i -e "s/\(${USERNAME}:[^:]*:\)[^:]*:[^:]*/\1${NEW_UID}:${NEW_GID}/" /etc/passwd; \
sed -i -e "s/\([^:]*:[^:]*:\)${OLD_GID}:/\1${NEW_GID}:/" /etc/group; \
chown -R $NEW_UID:$NEW_GID /home/$USERNAME

# copy code-server entrypoint
COPY ./code-server-entrypoint.sh /usr/local/bin/code-server-entrypoint
RUN chmod +x /usr/local/bin/code-server-entrypoint
ENTRYPOINT [ "/usr/local/bin/code-server-entrypoint" ]

USER ${USERNAME}

# install coder and extensions
RUN curl -fsSL https://code-server.dev/install.sh | sh -s -- --version="4.103.1" \
&& code-server --install-extension srl-labs.vscode-containerlab --force \
&& code-server --install-extension tuxtina.json2yaml --force

USER root
# add global workspace settings for code-server
COPY ./settings.json /home/${USERNAME}/.local/share/code-server/User
RUN chown avd /home/${USERNAME}/.local/share/code-server/User/settings.json

USER ${USERNAME}
133 changes: 133 additions & 0 deletions containers/arlabs/.devcontainer/code-server-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
#!/usr/bin/env bash

set +e

/usr/local/share/docker-init.sh

if [ ${LAB_NAME} ]; then
cd ${CONTAINERWSF}
wget "https://ankudinov.github.io/aclabs/coder_labs/${LAB_NAME}-coder.tar.gz"
tar -xzvf ${LAB_NAME}-coder.tar.gz
rm ${LAB_NAME}-coder.tar.gz
cp -r ${LAB_NAME}/labs/${LAB_NAME}/. .
rm -rf ${LAB_NAME}/
fi

if [ -f "${CONTAINERWSF}/addAliases.sh" ]; then
chmod +x ${CONTAINERWSF}/addAliases.sh
${CONTAINERWSF}/addAliases.sh
fi

# for D-in-D case container engine will be always Docker
# however we do not want to hardcode it for future cases
if [ "$(command -v podman)" ]; then
CONTAINER_ENGINE="podman"
elif [ "$(command -v docker)" ]; then
CONTAINER_ENGINE="docker"
else
echo "ERROR: Failed to find container engine. Please install docker or podman." >&2
exit 1
fi

# always prune old containers a clean lab on laptops
${CONTAINER_ENGINE} container prune -f

# check if ceos-lab image already present
if [ -z "$(${CONTAINER_ENGINE} image ls | grep 'arista/ceos')" ]; then
if [ "${ARISTA_TOKEN}" ]; then
# `uname -m` is used to find platform architecture
# currently we check for arm64 and aarch64 and expect everything else to be an x86 machine
echo "$(uname -m)"
if [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "arm64" ]; then
ardl get eos --format cEOSarm --version ${CEOS_LAB_VERSION} --import-docker
${CONTAINER_ENGINE} tag arista/ceos:${CEOS_LAB_VERSION} arista/ceos:latest
else
ardl get eos --format cEOS --version ${CEOS_LAB_VERSION} --import-docker
${CONTAINER_ENGINE} tag arista/ceos:${CEOS_LAB_VERSION} arista/ceos:latest
fi
# confirm that cEOS image was deleted just in case ardl failed to do that
rm -rf ${CONTAINERWSF}/cEOS*tar.xz >/dev/null 2>&1
rm -rf ${CONTAINERWSF}/cEOS*tar.xz.sha512sum >/dev/null 2>&1
else
# if ARISTA_TOKEN is not defined - we'll try find image in the workspace cEOS*.tar.xz
if [ -e ${CONTAINERWSF}/cEOS*tar.xz ]; then
${CONTAINER_ENGINE} import ${CONTAINERWSF}/cEOS*tar.xz arista/ceos:latest
rm ${CONTAINERWSF}/cEOS*tar.xz
# also delete SHA if it was copied, currently we do not check if archive was broken
rm -rf ${CONTAINERWSF}/cEOS*tar.xz.sha512sum >/dev/null 2>&1
echo "WARNING: cEOS-lab image was successfully imported from the workspace."
# also check if image was mounted to a special path
elif [ -e /img/cEOS-lab.tar.xz ]; then
${CONTAINER_ENGINE} import /img/cEOS-lab.tar.xz arista/ceos:latest
echo "WARNING: cEOS-lab image was successfully imported from /img/cEOS-lab.tar.xz."
else
# delete any cEOS-lab files if they were copied to workspace and image was imported before
rm ${CONTAINERWSF}/cEOS*tar.xz 2>&1
rm -rf ${CONTAINERWSF}/cEOS*tar.xz.sha512sum >/dev/null 2>&1
echo "WARNING: arista.com token was not defined and cEOS-lab image is not present in container workspace!"
fi 2>/dev/null
fi
else
echo "WARNING: cEOS-lab image already present. Skipping the image pull/download."
fi

if [ "${CV_API_TOKEN}" ]; then
if [ "${CVURL}" ]; then
CVTOKEN=$(curl -H "Authorization: Bearer ${CV_API_TOKEN}" "https://www.${CVURL}/api/v3/services/admin.Enrollment/AddEnrollmentToken" -d '{"enrollmentToken":{"reenrollDevices":["*"],"validFor":"24h"}}' | sed -n 's|.*"token":"\([^"]*\)".*|\1|p')
else
CVTOKEN=$(curl -H "Authorization: Bearer ${CV_API_TOKEN}" "https://www.cv-staging.corp.arista.io/api/v3/services/admin.Enrollment/AddEnrollmentToken" -d '{"enrollmentToken":{"reenrollDevices":["*"],"validFor":"24h"}}' | sed -n 's|.*"token":"\([^"]*\)".*|\1|p')
fi
if [ "${CVTOKEN}" ]; then
echo "$CVTOKEN" > ${CONTAINERWSF}/clab/cv-onboarding-token
else
echo "ERROR: failed to generate onboarding token!"
fi
else
# add default to avoid clab failing due to missing file
echo "CAFECAFE" > ${CONTAINERWSF}/clab/cv-onboarding-token
fi

if [ -f "${CONTAINERWSF}/postCreate.sh" ]; then
chmod +x ${CONTAINERWSF}/postCreate.sh
${CONTAINERWSF}/postCreate.sh
# delete postCreate.sh after use to avoid confusing lab user
rm ${CONTAINERWSF}/postCreate.sh
fi

# init demo dir as Git repo if requested for this demo env
if ${GIT_INIT}; then
cd ${CONTAINERWSF}
# if not a git repo already - init
if [ -z "$(git status 2>/dev/null)" ]; then
git init
git config --global --add safe.directory ${PWD}
if [ -z "$(git config user.name)" ]; then git config user.name "Lab User"; fi
if [ -z "$(git config user.email)" ]; then git config user.email [email protected]; fi
git add .
git commit -m "git init"
fi
fi

code-server --bind-addr 0.0.0.0:8080 --auth password --disable-telemetry --disable-update-check --disable-workspace-trust "${CONTAINERWSF}" &

# check if image is still missing and print a warning
if [ -z "$(${CONTAINER_ENGINE} image ls | grep 'arista/ceos')" ]; then
echo "WARNING: cEOS-lab image download failed. Try to upload and import it manually."
echo " Please make sure that image is imported with a correct name - arista/ceos:latest"
echo " The lab will not auto start! Run 'make start' when image is ready."
else
cd ${CONTAINERWSF}
make start
fi

# Execute command from docker cli if any.
if [ ${@+True} ]; then
exec "$@"
# Otherwise just enter sh or zsh.
else
if [ -f "/bin/zsh" ]; then
exec zsh
else
exec sh
fi
fi
17 changes: 17 additions & 0 deletions containers/arlabs/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"build": {
"dockerfile": "Dockerfile",
"args": {
// "FROM_IMAGE": "${localEnv:FROM_IMAGE}",
"FROM_IMAGE": "ghcr.io/ankudinov/aclabs/lab-base",
// "FROM_VARIANT": "${localEnv:FROM_VARIANT}",
"FROM_VARIANT": "python3.11-avd-v5.5.1-clab0.68.0-rev1.7",
// "USERNAME": "${localEnv:USERNAME}",
"USERNAME": "avd"
}
},
// "forwardPorts": ["localhost:8080"],
// "appPort": [8080],
// "overrideCommand": false,
"containerUser": "avd"
}
3 changes: 3 additions & 0 deletions containers/arlabs/.devcontainer/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"workbench.startupEditor": "readme"
}
20 changes: 20 additions & 0 deletions containers/coder/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG FROM_IMAGE
ARG FROM_VARIANT

FROM ${FROM_IMAGE}:${FROM_VARIANT}

ARG USERNAME

USER root

# copy code-server entrypoint
COPY ./code-server-entrypoint.sh /usr/local/bin/code-server-entrypoint
RUN chmod +x /usr/local/bin/code-server-entrypoint
ENTRYPOINT [ "/usr/local/bin/code-server-entrypoint" ]

USER ${USERNAME}

# install coder and extensions
RUN curl -fsSL https://code-server.dev/install.sh | sh -s -- --version="4.103.1" \
&& code-server --install-extension srl-labs.vscode-containerlab --force \
&& code-server --install-extension tuxtina.json2yaml --force
Loading