Skip to content

Instantly share code, notes, and snippets.

@edsonmgoz
Created February 12, 2026 00:16
Show Gist options
  • Select an option

  • Save edsonmgoz/024d967b98ac22df92975b5989b81adf to your computer and use it in GitHub Desktop.

Select an option

Save edsonmgoz/024d967b98ac22df92975b5989b81adf to your computer and use it in GitHub Desktop.
Hello World NodeJS example using NO ROOT user & group
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