From 260ac3433aa8ac86a9b3de9ea791f7440a94a8c3 Mon Sep 17 00:00:00 2001 From: Fernando Jose Gonzalez Sierra Date: Tue, 9 Apr 2024 13:19:36 +0200 Subject: [PATCH 1/2] Arreglo Hotspots Es una prueba al final xd --- questionservice/Dockerfile | 5 +++-- questionservice/server.js | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/questionservice/Dockerfile b/questionservice/Dockerfile index 438c0b9..c36a2bc 100644 --- a/questionservice/Dockerfile +++ b/questionservice/Dockerfile @@ -8,13 +8,14 @@ WORKDIR /usr/src/questionservice COPY package*.json ./ #Create an optimized version of the webapp -RUN npm install axios --ignore-scripts +RUN npm install axios # Install app dependencies RUN npm install --ignore-scripts # Copy the app source code to the working directory -COPY . . /usr/src/questionservice/ +COPY server.js ./ +COPY questions.json ./ # Define the command to run your app CMD ["node", "server.js"] diff --git a/questionservice/server.js b/questionservice/server.js index c816c78..28e42c2 100644 --- a/questionservice/server.js +++ b/questionservice/server.js @@ -70,7 +70,9 @@ app.get('/pregunta', async (req, res) => { } // Mezclamos las respuestas for (let i = answers.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)); + buf = crypto.randomBytes(1) + randomValue = buf[0]/255 + const j = Math.floor(randomValue * (i + 1)); // Intercambiamos las respuestas en los índices i y j [answers[i], answers[j]] = [answers[j], answers[i]]; } From 06823e513839911aaa2138aeb4dfd872be463d22 Mon Sep 17 00:00:00 2001 From: Fernando Jose Gonzalez Sierra Date: Tue, 9 Apr 2024 13:35:02 +0200 Subject: [PATCH 2/2] Cambios dockerfile y sonarproject Prueba --- gatewayservice/Dockerfile | 2 +- questionservice/Dockerfile | 2 +- sonar-project.properties | 3 ++- userservice/authservice/Dockerfile | 3 ++- userservice/userservice/Dockerfile | 3 ++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gatewayservice/Dockerfile b/gatewayservice/Dockerfile index 136cbc0..47f2bb9 100644 --- a/gatewayservice/Dockerfile +++ b/gatewayservice/Dockerfile @@ -11,7 +11,7 @@ COPY package*.json ./ RUN npm install --ignore-scripts # Copy the app source code to the working directory -COPY . . /usr/src/gatewayservice/ +COPY gateway-service.js ./ # Define the command to run your app CMD ["node", "gateway-service.js"] diff --git a/questionservice/Dockerfile b/questionservice/Dockerfile index c36a2bc..3fe633a 100644 --- a/questionservice/Dockerfile +++ b/questionservice/Dockerfile @@ -8,7 +8,7 @@ WORKDIR /usr/src/questionservice COPY package*.json ./ #Create an optimized version of the webapp -RUN npm install axios +RUN npm install axios --ignore-scripts # Install app dependencies RUN npm install --ignore-scripts diff --git a/sonar-project.properties b/sonar-project.properties index acbc46c..c96a4d3 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -11,7 +11,8 @@ sonar.language=js sonar.projectName=wiq_es05a sonar.coverage.exclusions=**/*.test.js -sonar.coverage.exclusions=* +sonar.coverage.exclusions=**/*.json, **/*.yaml +sonar.coverage.exclusions=**/Dockerfile, **/*.dockerfile sonar.sources=webapp/src/components,userservice/authservice,userservice/userservice,gatewayservice,questionservice sonar.sourceEncoding=UTF-8 sonar.exclusions=node_modules/** diff --git a/userservice/authservice/Dockerfile b/userservice/authservice/Dockerfile index d6d0fb5..e5fc65d 100644 --- a/userservice/authservice/Dockerfile +++ b/userservice/authservice/Dockerfile @@ -11,7 +11,8 @@ COPY package*.json ./ RUN npm install --ignore-scripts # Copy the app source code to the working directory -COPY . . / /usr/src/authservice/ +COPY auth-service.js ./ +COPY auth-model.js ./ # Expose the port the app runs on EXPOSE 8002 diff --git a/userservice/userservice/Dockerfile b/userservice/userservice/Dockerfile index d8f9099..d80ffb6 100644 --- a/userservice/userservice/Dockerfile +++ b/userservice/userservice/Dockerfile @@ -11,7 +11,8 @@ COPY package*.json ./ RUN npm install --ignore-scripts # Copy the app source code to the working directory -COPY . . /usr/src/userservice/ +COPY user-service.js ./ +COPY user-model.js ./ # Expose the port the app runs on EXPOSE 8001