Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for SSHD in devcontainer #135

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions devcontainer/test-fixtures/dind-devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"build": {
"context": "../../..",
"dockerfile": "../../../Dockerfile",
"target": "devcontainer"
},
"overrideCommand": false,
"privileged": true,
"containerEnv": {
"SSHD_ENABLED": "true",
"SSHD_PORT": "2222",
"NODE_NAME": "localhost"
},
"runArgs": ["--publish=2222:22"],
"postCreateCommand": [".devcontainer/post_create.sh"]
}
23 changes: 22 additions & 1 deletion devcontainer/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ cd "${script_dir}/.."

devcontainer build --workspace-folder .

container_id=$(devcontainer up --workspace-folder . | tee /dev/stderr | jq -r .containerId)
container_id=$(
devcontainer up --workspace-folder . |
tee /dev/stderr |
jq -r .containerId
)

trap 'docker rm -f "${container_id}"' EXIT

Expand All @@ -20,3 +24,20 @@ devcontainer exec --workspace-folder . printenv | sort | tee /dev/stderr | grep

# check if dond shim is setup correctly
devcontainer exec --workspace-folder . bash -c 'DOND_SHIM_PRINT_COMMAND=true docker version' | tee /dev/stderr | grep -q '^docker.orig version$'

docker rm -f "${container_id}"

container_id=$(
devcontainer up --workspace-folder . --config devcontainer/test-fixtures/dind-devcontainer/devcontainer.json |
tee /dev/stderr |
jq -r .containerId
)

devcontainer exec --workspace-folder . --config devcontainer/test-fixtures/dind-devcontainer/devcontainer.json \
docker version

devcontainer exec --workspace-folder . --config devcontainer/test-fixtures/dind-devcontainer/devcontainer.json \
env IGNORE_FAILURE=false /ssh-command/get.sh

ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR ssh://devcontainer@localhost:2222 \
docker version