Skip to content

Commit

Permalink
Merge pull request #614 from marp-team/improve-container-detection
Browse files Browse the repository at this point in the history
Disable Chrome sandbox if running CLI as root
  • Loading branch information
yhatt authored Oct 30, 2024
2 parents 6313b2a + ca070e1 commit 7a5da0c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ commands:
command: npm run test:coverage -- --ci -i --reporters=default --reporters=jest-junit
environment:
JEST_JUNIT_OUTPUT_DIR: tmp/test-results
MARP_TEST_CI: 1

- codecov/upload:
flags: linux
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
# https://stackoverflow.com/a/59365905
- name: Jest
env:
CI: true
MARP_TEST_CI: 1
run: >-
npm run test:coverage -- --ci -i --reporters=default --reporters=jest-junit --forceExit ||
npm run test:coverage -- --ci -i --reporters=default --reporters=jest-junit --forceExit --no-cache ||
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Fixed

- Disable Chrome sandbox if running CLI as root ([#611](https://github.com/marp-team/marp-cli/issues/611), [#614](https://github.com/marp-team/marp-cli/pull/614))

### Removed

- Get rid of `sharp` dependency in favor of using browser in JPEG image conversion with WebDriver BiDi ([#610](https://github.com/marp-team/marp-cli/pull/610))
Expand Down
1 change: 1 addition & 0 deletions src/browser/browsers/chrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class ChromeBrowser extends Browser {

private async puppeteerArgsEnableSandbox() {
if (process.env.CHROME_NO_SANDBOX) return false
if (process.getuid?.() === 0) return false // Running as root without --no-sandbox is not supported.
if (isInsideContainer()) return false
if (await isWSL()) return false

Expand Down
2 changes: 1 addition & 1 deletion src/utils/container.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _isInsideContainer from 'is-inside-container'

export const isInsideContainer = () =>
isOfficialDockerImage() || (!process.env.CI && _isInsideContainer())
isOfficialDockerImage() || (_isInsideContainer() && !process.env.MARP_TEST_CI)

export const isOfficialDockerImage = () => !!process.env.MARP_USER

0 comments on commit 7a5da0c

Please sign in to comment.