Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Add ability to use Dev Containers locally #3744

Merged
merged 9 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM docker.cernerrepos.net/ion/ion-node:5
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "TerraCore",
"dockerComposeFile": "docker-compose.yml",
"service": "vscode",
"shutdownAction": "stopCompose",
"workspaceFolder": "/workspace",
"postCreateCommand": "",
"runServices": [
"vscode"
],
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"james-yu.latex-workshop",
"eamodio.gitlens",
"shardulm94.trailing-spaces",
"stkb.rewrap",
"vscode-icons-team.vscode-icons",
"streetsidesoftware.code-spell-checker"
]
}
},
"forwardPorts": [8080]
}
43 changes: 43 additions & 0 deletions .devcontainer/docker-compose-wdio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "3"

services:
selenium-hub:
image: selenium/hub:3.141.59-zirconium
container_name: selenium-hub
ports:
- "4444:4444"
healthcheck:
test: ["CMD", "/opt/bin/check-grid.sh"]
interval: 15s
timeout: 30s
retries: 5

chrome:
image: selenium/node-chrome:3.141.59-zirconium
# Volume mounting is necessary to ensure the browser does not crash inside the docker container.
# For more details see:
# https://github.com/SeleniumHQ/docker-selenium#running-the-images
# https://bugs.chromium.org/p/chromium/issues/detail?id=519952
# https://bugzilla.mozilla.org/show_bug.cgi?id=1338771#c10
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444

firefox:
image: selenium/node-firefox:3.141.59-zirconium
# Volume mounting is necessary to ensure the browser does not crash inside the docker container.
# For more details see:
# https://github.com/SeleniumHQ/docker-selenium#running-the-images
# https://bugs.chromium.org/p/chromium/issues/detail?id=519952
# https://bugzilla.mozilla.org/show_bug.cgi?id=1338771#c10
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
13 changes: 13 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3"

services:
vscode:
network_mode: host
build: .
volumes:
- ../:/workspace
# Docker socket to access Docker server
- /var/run/docker.sock:/var/run/docker.sock
# Git config
- ~/.gitconfig:/root/.gitconfig
entrypoint: /bin/sh -c "while sleep 1000; do :; done"
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- [Packages Requiring I18n](#packages-requiring-i18n)
- [Contributing](#contributing)
- [Local Development](#local-development)
- [Local Development using Docker (Dev Containers)](#docker-local-development)
- [LICENSE](#license)

<h2 id="packages">
Expand Down Expand Up @@ -175,6 +176,32 @@ npm install
npm run test
```

<h2 id="docker-local-development">
Local Development using Docker (Dev Containers)
</h2>

1. Install docker https://www.docker.com/.
2. Install [Microsoft VS Code](https://code.visualstudio.com/Download)
3. Clone this repo.
4. Open this repo in VS Code.
5. Install the Dev Container extension.
- Navigate to View -> Extension -> Search for and install _Dev Containers_
- More information on [Dev Containers](https://code.visualstudio.com/docs/devcontainers/containers)
6. Build the dev container.
- Navigate to View -> Command Palette -> Open Workspace In Container or Reopen Folder Locally
7. You're now running in a dev container. Use the terminal of the dev container to issue any npm commands.
8. Before running any WDIO tests (`npm run test` or `npm run wdio`), make sure to perform the following steps:
- Open a new terminal (outside the dev container) and navigate to ".devcontainer/" path in your repository.
- Execute the command `"docker compose -f docker-compose-wdio.yml up"`. Selenium hub should spin up. Leave this running in the background. If you see errors saying "container name already exists", run `"docker container prune"` command followed by selecting "y" to clear up any unused containers and try running the previous command again.
- Edit the root package.json file WDIO scripts to include `--disableSeleniumService=true` flag. This will disable the selenium service from spinning up again.
For example:
```sh
"scripts": {
"wdio": "terra wdio --disableSeleniumService=true --themes terra-default-theme clinical-lowlight-theme orion-fusion-theme"
}
```
- You can now run `npm run test` or any npm command which runs WDIO tests from inside the Dev Container.

<h2 id="license">
LICENSE
</h2>
Expand Down