Skip to content

Commit 062438a

Browse files
authored
Add dev container support (#7758)
1 parent a50bb7e commit 062438a

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

.devcontainer/devcontainer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "HLS.JS Dev Container",
3+
"image": "mcr.microsoft.com/devcontainers/base:bookworm",
4+
"containerEnv": {
5+
"IN_DEV_CONTAINER": "true",
6+
"CHROME_BIN": "/usr/bin/chromium"
7+
},
8+
"customizations": {
9+
"vscode": {
10+
"extensions": ["esbenp.prettier-vscode"]
11+
}
12+
},
13+
"postCreateCommand": "bash .devcontainer/post-create.sh"
14+
}

.devcontainer/post-create.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "Installing nvm..."
5+
# v0.40.4
6+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/62387b8f92aa012d48202747fd75c40850e5e261/install.sh | bash
7+
export NVM_DIR="$HOME/.nvm"
8+
\. "$NVM_DIR/nvm.sh"
9+
10+
echo "Installing node..."
11+
nvm install "$(< .node-version)"
12+
13+
echo "Installing chromium..."
14+
sudo apt-get update -y
15+
sudo apt-get install -y chromium
16+
17+
echo "Done!"

karma.conf.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const { buildRollupConfig, BUILD_TYPE, FORMAT } = require('./build-config');
33
// Do not add coverage for JavaScript debugging when running `test:unit:debug`
44
// eslint-disable-next-line no-undef
55
const includeCoverage = !process.env.DEBUG_UNIT_TESTS && !process.env.CI;
6+
const isDevContainer = process.env.IN_DEV_CONTAINER === 'true';
67

78
const rollupPreprocessor = buildRollupConfig({
89
type: BUILD_TYPE.full,
@@ -70,7 +71,14 @@ module.exports = function (config) {
7071

7172
// start these browsers
7273
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
73-
browsers: ['ChromeHeadless'],
74+
browsers: [isDevContainer ? 'ChromeHeadlessNoSandbox' : 'ChromeHeadless'],
75+
76+
customLaunchers: {
77+
ChromeHeadlessNoSandbox: {
78+
base: 'ChromeHeadless',
79+
flags: ['--no-sandbox'],
80+
},
81+
},
7482

7583
// Continuous Integration mode
7684
// if true, Karma captures browsers, runs the tests and exits

0 commit comments

Comments
 (0)