Created
February 12, 2026 00:16
-
-
Save edsonmgoz/024d967b98ac22df92975b5989b81adf to your computer and use it in GitHub Desktop.
Hello World NodeJS example using NO ROOT user & group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM node:18-slim | |
| WORKDIR /app | |
| # Crear usuario/grupo NO ROOT | |
| RUN groupadd --gid 10001 appgroup \ | |
| && useradd --uid 10001 --gid 10001 --create-home --home-dir /home/app appuser \ | |
| && chown -R appuser:appgroup /app | |
| # Copiar dependencias | |
| COPY --chown=appuser:appgroup package*.json ./ | |
| # Ejecutar como usuario NO ROOT | |
| USER appuser | |
| RUN npm install | |
| # Copiar código fuente | |
| COPY --chown=appuser:appgroup app.js ./ | |
| EXPOSE 3000 | |
| CMD ["node", "app.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment