Allow this to run in a non-root enviroment #5476
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change file permissions so that a non root user can run the container.
Description
Currently the container is built for running as root. However, in some circumstances it is desired to not run as root. Currently this simply fails (see log below). This change grants the necessary permission on the files, so that the server starts up, even when the effective user is not root.
Motivation and Context
Running the container with a non-root user simply fails:
$ docker run --rm -ti -u 1 docker.io/swaggerapi/swagger-ui:latest fs.js:115 throw err; ^ Error: EACCES: permission denied, open '/usr/share/nginx/html/index.html' at Object.openSync (fs.js:439:3) at Object.writeFileSync (fs.js:1190:35) at Object.<anonymous> (/usr/share/nginx/configurator/index.js:38:4) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) at startup (internal/bootstrap/node.js:282:19)In some environment however, it is desirable to run this as "any" (non-root) user.
How Has This Been Tested?
docker run --rm -ti -u 1 docker.io/swaggerapi/swagger-ui:latestScreenshots (if appropriate):
n/a
Checklist
My PR contains...
src/is unmodified: changes to documentation, CI, metadata, etc.)package.json)My changes...
Documentation
Automated tests