Skip to content

Commit

Permalink
arreglando Security Hotspots v2
Browse files Browse the repository at this point in the history
  • Loading branch information
UO290054 committed Apr 28, 2024
1 parent 7ebc0cc commit 1736bd8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
10 changes: 9 additions & 1 deletion users/authservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ WORKDIR /usr/src/authservice
COPY package*.json ./

# Install app dependencies
RUN npm install bcrypt --ignore-scripts
RUN npm install --ignore-scripts

# Copy the app source code to the working directory
COPY . .

# Create a new non-root user and group
RUN addgroup -S myusergroup && adduser -S myuser -G myusergroup

# Change the ownership of the working directory to the newly created user
RUN chown -R myuser:myusergroup /usr/src/authservice

# Switch to the new non-root user
USER myuser

# Expose the port the app runs on
EXPOSE 8002

Expand Down
22 changes: 13 additions & 9 deletions users/userservice/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# Use an official Node.js runtime as a parent image
# Usa una imagen oficial de Node.js como imagen base
FROM node:20

# Set the working directory in the container
# Establece el directorio de trabajo en el contenedor
WORKDIR /usr/src/userservice

# Copy package.json and package-lock.json to the working directory
# Copia package.json y package-lock.json al directorio de trabajo
COPY package*.json ./

# Install app dependencies
RUN npm install bcrypt --ignore-scripts && \
npm install --ignore-scripts
# Instala las dependencias de la aplicación
RUN npm install --ignore-scripts

# Copy the app source code to the working directory
# Copia el código fuente de la aplicación al directorio de trabajo
COPY . .

# Expose the port the app runs on
# Cambia a un usuario no privilegiado
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot
USER nonroot

# Expone el puerto en el que se ejecuta la aplicación
EXPOSE 8001

# Define the command to run your app
# Define el comando para ejecutar la aplicación
CMD ["node", "user-service.js"]

0 comments on commit 1736bd8

Please sign in to comment.