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

[Feature] Headless browser (chrome/chromium/firefox) #189

Open
snebjorn opened this issue Sep 29, 2022 · 6 comments
Open

[Feature] Headless browser (chrome/chromium/firefox) #189

snebjorn opened this issue Sep 29, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@snebjorn
Copy link

I'd love if I could add a headless browser to my dev container using the dev container features.

"features": {
  "headless-chrome": "latest",
  "headless-chromium": "latest",
  "headless-firefox": "latest",
}

All (that I know) JS/TS testing frameworks need it. Manually adding it without having to resort to --no-sandbox is very complicated. I have yet to succeed at it 😞
--no-sandbox is considered insecure and strongly discouraged.

@joshspicer
Copy link
Member

joshspicer commented Sep 29, 2022

I agree, this sounds like an awesome Feature to add!

Not exactly the same as what you're looking for, but want to point you to the existing desktop-lite Feature, that spins up a basic desktop environment that one can connect to via VNC. (https://github.com/devcontainers/features/tree/main/src/desktop-lite)


I'm not sure if this is something that would interest you in implementing, but we have starter code for self-authoring Features if it interested you to give it a go. We're investing a lot in making it quick/easy for members of the community to self-author (spec), and would welcome any feedback on the process.

https://github.com/devcontainers/feature-template

Useful Feature collections can then be registered via PR and will appear in our tooling for the rest of the community to enjoy (see some existing community Features at the bottom of this list 😃 https://containers.dev/features)

@joshspicer joshspicer added the enhancement New feature or request label Sep 29, 2022
@snebjorn
Copy link
Author

snebjorn commented Oct 5, 2022

@joshspicer thanks for the links. I gave it a shot. But it seems there's an issue with running the tests. Not sure what is going on.

https://github.com/snebjorn/devcontainer-feature/actions/runs/3193079539/jobs/5211272135

When running locally I get this error:

root ➜ /workspaces/devcontainer-feature (main ✗) $ devcontainer features test --features chromium --base-image mcr.microsoft.com/devcontainers/base:ubuntu .

┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
|    dev container 'features' |   
│           v0.19.0           │
└ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘

>  baseImage:         mcr.microsoft.com/devcontainers/base:ubuntu
>  Target Folder:     /workspaces/devcontainer-feature
>  features:          chromium
>  workspaceFolder:   /tmp/devcontainercli/container-features-test/1665008951184

⏳ Building test container...

[1 ms] @devcontainers/cli 0.19.0. Node.js v18.9.1. linux 5.10.16.3-microsoft-standard-WSL2 x64.
[518 ms] Start: Run: docker buildx build --load --build-context dev_containers_feature_content_source=/tmp/devcontainercli-root/container-features/0.19.0-1665008951744 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/base:ubuntu --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-1665008951184-78f48eade62e871b44e50fb7260d24e9-features -f /tmp/devcontainercli-root/container-features/0.19.0-1665008951744/Dockerfile.extended /tmp/devcontainercli-root/empty-folder
[+] Building 16.8s (10/12)                                                      
[+] Building 17.0s (11/12)                                                      
 => [internal] load build definition from Dockerfile.extended              0.1s
[+] Building 17.1s (11/12)                                                      
 => [internal] load build definition from Dockerfile.extended              0.1s
[+] Building 17.3s (11/12)                                                      
 => [internal] load build definition from Dockerfile.extended              0.1s
[+] Building 17.4s (11/12)                                                      
 => [internal] load build definition from Dockerfile.extended              0.1s
 => => transferring dockerfile: 550B                                       0.0s
 => [internal] load .dockerignore                                          0.1s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4              16.0s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b  0.0s
 => [internal] load .dockerignore                                          0.0s
[+] Building 17.5s (12/12) FINISHED                                             
 => [internal] load build definition from Dockerfile.extended              0.1s
 => => transferring dockerfile: 550B                                       0.0s
 => [internal] load .dockerignore                                          0.1s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4              16.0s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b  0.0s
 => [internal] load .dockerignore                                          0.0s
 => [internal] load build definition from Dockerfile.extended              0.0s
 => [internal] load metadata for mcr.microsoft.com/devcontainers/base:ubu  0.2s
 => [context dev_containers_feature_content_source] load .dockerignore     0.1s
 => => transferring dev_containers_feature_content_source: 2B              0.0s
 => [context dev_containers_feature_content_source] load from client       0.1s
 => => transferring dev_containers_feature_content_source: 20.01kB         0.0s
 => CACHED [dev_containers_target_stage 1/3] FROM mcr.microsoft.com/devco  0.0s
 => [dev_containers_target_stage 2/3] COPY --from=dev_containers_feature_  0.1s
 => ERROR [dev_containers_target_stage 3/3] RUN cd /tmp/build-features/ch  0.6s
------                                                                          
 > [dev_containers_target_stage 3/3] RUN cd /tmp/build-features/chromium_1 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh:
#0 0.496 ===========================================================================
#0 0.496 Feature       : ./chromium                                             
#0 0.496 Description   : Chromium                                               
#0 0.496 Id            : Unknown                                                
#0 0.496 Version       : 1.0.0
#0 0.496 Documentation : 
#0 0.496 Options       :
#0 0.496 
#0 0.496 ===========================================================================
#0 0.506 ./devcontainer-features-install.sh: 26: ./install.sh: not found
#0 0.506 ERROR: Feature "./chromium" (Unknown) failed to install!
------
ERROR: failed to solve: executor failed running [/bin/sh -c cd /tmp/build-features/chromium_1 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh]: exit code: 127
[-] Failed to launch container:

Command failed: docker buildx build --load --build-context dev_containers_feature_content_source=/tmp/devcontainercli-root/container-features/0.19.0-1665008951744 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/base:ubuntu --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-1665008951184-78f48eade62e871b44e50fb7260d24e9-features -f /tmp/devcontainercli-root/container-features/0.19.0-1665008951744/Dockerfile.extended /tmp/devcontainercli-root/empty-folder

Also where is the docs for dev-container-features-test-lib?

@jkeech
Copy link
Contributor

jkeech commented Oct 5, 2022

I'm not sure about the local test execution, but the one in the action shows the following error: https://github.com/snebjorn/devcontainer-feature/actions/runs/3193079539/jobs/5211272135#step:4:151

./install.sh: 15: Bad substitution

That maps to this line in the install script: https://github.com/snebjorn/devcontainer-feature/blob/main/src/chromium/install.sh#L15, so I think the $PATH substitution is not working properly in the script.

@snebjorn
Copy link
Author

snebjorn commented Oct 6, 2022

I copied the script from here https://github.com/devcontainers/features/blob/main/src/dotnet/install.sh#L33-L64
Does it not work or do I need to something to make it work?

@samruddhikhandale
Copy link
Member

Hi @snebjorn, were you able to fix the test? Happy to take a look.

@snebjorn
Copy link
Author

snebjorn commented Nov 6, 2022

Hi @samruddhikhandale I don't recall what was the error when running the test on github.
But running it locally still doesn't work.

vscode ➜ /workspaces/devcontainer-feature (main) $ devcontainer features test --features chromium --base-image mcr.microsoft.com/devcontainers/base:debian .

┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐
|    dev container 'features' |   
│           v0.23.2           │
└ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘

>  baseImage:         mcr.microsoft.com/devcontainers/base:debian
>  Target Folder:     /workspaces/devcontainer-feature
>  features:          chromium
>  workspaceFolder:   /tmp/devcontainercli/container-features-test/1667776825229

⏳ Building test container...

[1 ms] @devcontainers/cli 0.23.2. Node.js v18.10.0. linux 5.10.102.1-microsoft-standard-WSL2 x64.
[484 ms] Start: Run: docker buildx build --load --build-context dev_containers_feature_content_source=/tmp/devcontainercli-vscode/container-features/0.23.2-1667776825751 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/base:debian --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-1667776825229-2b0794bc36a5dc7b81f7946755ddffcb-features -f /tmp/devcontainercli-vscode/container-features/0.23.2-1667776825751/Dockerfile.extended /tmp/devcontainercli-vscode/empty-folder
[+] Building 11.4s (13/15)                                                      
 => [internal] load build definition from Dockerfile.extended              0.1s
 => => transferring dockerfile: 1.02kB                                     0.0s
 => [internal] load .dockerignore                                          0.1s
 => => transferring context: 2B                                            0.0s
[+] Building 11.5s (13/15)                                                      
 => [internal] load build definition from Dockerfile.extended              0.1s
 => => transferring dockerfile: 1.02kB                                     0.0s
 => [internal] load .dockerignore                                          0.1s
 => => transferring context: 2B                                            0.0s
[+] Building 11.7s (13/15)                                                      
 => [internal] load build definition from Dockerfile.extended              0.1s
 => => transferring dockerfile: 1.02kB                                     0.0s
 => [internal] load .dockerignore                                          0.1s
 => => transferring context: 2B                                            0.0s
[+] Building 11.8s (14/15)                                                      
 => [internal] load build definition from Dockerfile.extended              0.1s
 => => transferring dockerfile: 1.02kB                                     0.0s
 => [internal] load .dockerignore                                          0.1s
 => => transferring context: 2B                                            0.0s
[+] Building 11.8s (14/15)                                                      
 => [internal] load build definition from Dockerfile.extended              0.1s
 => => transferring dockerfile: 1.02kB                                     0.0s
 => [internal] load .dockerignore                                          0.1s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4              10.5s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b  0.0s
 => [internal] load build definition from Dockerfile.extended              0.0s
 => [internal] load .dockerignore                                          0.0s
 => [internal] load metadata for mcr.microsoft.com/devcontainers/base:deb  0.9s
 => [context dev_containers_feature_content_source] load .dockerignore     0.1s
 => => transferring dev_containers_feature_content_source: 2B              0.0s
 => [context dev_containers_feature_content_source] load from client       0.1s
 => => transferring dev_containers_feature_content_source: 22.08kB         0.0s
 => [dev_containers_feature_content_normalize 1/3] FROM mcr.microsoft.com  0.0s
 => CACHED [dev_containers_feature_content_normalize 2/3] COPY --from=dev  0.0s
 => CACHED [dev_containers_feature_content_normalize 3/3] RUN chmod -R 07  0.0s
 => CACHED [dev_containers_target_stage 2/4] COPY --from=dev_containers_f  0.0s
 => CACHED [dev_containers_target_stage 3/4] RUN echo "_CONTAINER_USER_HO  0.0s
 => ERROR [dev_containers_target_stage 4/4] RUN cd /tmp/build-features/ch  0.6s
------
 > [dev_containers_target_stage 4/4] RUN cd /tmp/build-features/chromium_1 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh:
#0 0.493 ===========================================================================
#0 0.493 Feature       : ./chromium
#0 0.493 Description   : Chromium
#0 0.493 Id            : Unknown
#0 0.493 Version       : 1.0.0
#0 0.493 Documentation : 
#0 0.493 Options       :
#0 0.493 
#0 0.493 ===========================================================================
#0 0.503 ./devcontainer-features-install.sh: 27: ./install.sh: not found
#0 0.503 ERROR: Feature "./chromium" (Unknown) failed to install!
------
ERROR: failed to solve: executor failed running [/bin/sh -c cd /tmp/build-features/chromium_1 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh]: exit code: 127
[-] Failed to launch container:

Command failed: docker buildx build --load --build-context dev_containers_feature_content_source=/tmp/devcontainercli-vscode/container-features/0.23.2-1667776825751 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/base:debian --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-1667776825229-2b0794bc36a5dc7b81f7946755ddffcb-features -f /tmp/devcontainercli-vscode/container-features/0.23.2-1667776825751/Dockerfile.extended /tmp/devcontainercli-vscode/empty-folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants