From 757a88fd838ebb3798ec22a8f81909c3bb24339d Mon Sep 17 00:00:00 2001 From: CANCI0 Date: Wed, 21 Feb 2024 15:22:07 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Se=20ha=20dockerizado=20el=20m=C3=B3dulo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- questions/.dockerignore | 2 ++ questions/Dockerfile | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 questions/.dockerignore create mode 100644 questions/Dockerfile diff --git a/questions/.dockerignore b/questions/.dockerignore new file mode 100644 index 00000000..3091757a --- /dev/null +++ b/questions/.dockerignore @@ -0,0 +1,2 @@ +node_modules +coverage \ No newline at end of file diff --git a/questions/Dockerfile b/questions/Dockerfile new file mode 100644 index 00000000..ae8f3e41 --- /dev/null +++ b/questions/Dockerfile @@ -0,0 +1,20 @@ +# Use an official Node.js runtime as a parent image +FROM node:20 + +# Set the working directory in the container +WORKDIR /usr/src/questionservice + +# Copy package.json and package-lock.json to the working directory +COPY package*.json ./ + +# Install app dependencies +RUN npm install + +# Copy the app source code to the working directory +COPY . . + +# Expose the port the app runs on +EXPOSE 8003 + +# Define the command to run your app +CMD ["node", "question-service.js"] From 8933b43b4cfaf5e892f76122fd03ea31724803ff Mon Sep 17 00:00:00 2001 From: CANCI0 Date: Wed, 21 Feb 2024 15:50:01 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Se=20ha=20a=C3=B1adido=20el=20m=C3=B3dulo?= =?UTF-8?q?=20al=20docker-compose?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 22 ++++++++++++++++++- docker-compose.yml | 12 ++++++++++ {questions => questionservice}/.dockerignore | 0 {questions => questionservice}/Dockerfile | 0 .../data/literatura.json | 0 .../data/tematicas.json | 0 .../package-lock.json | 0 {questions => questionservice}/package.json | 0 .../question-service.js | 0 .../questionGen/GeneratorChooser.js | 0 .../questionGen/GenericGenerator.js | 0 11 files changed, 33 insertions(+), 1 deletion(-) rename {questions => questionservice}/.dockerignore (100%) rename {questions => questionservice}/Dockerfile (100%) rename {questions => questionservice}/data/literatura.json (100%) rename {questions => questionservice}/data/tematicas.json (100%) rename {questions => questionservice}/package-lock.json (100%) rename {questions => questionservice}/package.json (100%) rename {questions => questionservice}/question-service.js (100%) rename {questions => questionservice}/questionGen/GeneratorChooser.js (100%) rename {questions => questionservice}/questionGen/GenericGenerator.js (100%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0520121f..7e47df19 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,10 +17,12 @@ jobs: - run: npm --prefix users/userservice ci - run: npm --prefix gatewayservice ci - run: npm --prefix webapp ci + - run: npm --prefix questionservice ci - run: npm --prefix users/authservice test -- --coverage - run: npm --prefix users/userservice test -- --coverage - run: npm --prefix gatewayservice test -- --coverage - run: npm --prefix webapp test -- --coverage + - run: npm --prefix questionservice test -- --coverage - name: Analyze with SonarCloud uses: sonarsource/sonarcloud-github-action@master env: @@ -37,6 +39,7 @@ jobs: - run: npm --prefix users/authservice install - run: npm --prefix users/userservice install - run: npm --prefix gatewayservice install + - run: npm --prefix questionservice install - run: npm --prefix webapp install - run: npm --prefix webapp run build - run: npm --prefix webapp run test:e2e @@ -94,6 +97,23 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io workdir: users/userservice + docker-push-questionservice: + name: Push user service Docker Image to GitHub Packages + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + needs: [e2e-tests] + steps: + - uses: actions/checkout@v4 + - name: Publish to Registry + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: arquisoft/wiq_es1a/questionservice + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io + workdir: questionservice docker-push-gatewayservice: name: Push gateway service Docker Image to GitHub Packages runs-on: ubuntu-latest @@ -114,7 +134,7 @@ jobs: deploy: name: Deploy over SSH runs-on: ubuntu-latest - needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp] + needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp,docker-push-questionservice] steps: - name: Deploy over SSH uses: fifsky/ssh-action@master diff --git a/docker-compose.yml b/docker-compose.yml index 5ca2a021..fbc8d143 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,16 @@ services: networks: - mynetwork + questionservice: + container_name: questionservice-${teamname:-defaultASW} + image: ghcr.io/arquisoft/wiq_es1a/questionservice:latest + profiles: ["dev", "prod"] + build: ./questionservice + ports: + - "8003:8003" + networks: + - mynetwork + authservice: container_name: authservice-${teamname:-defaultASW} image: ghcr.io/arquisoft/wiq_es1a/authservice:latest @@ -48,11 +58,13 @@ services: - mongodb - userservice - authservice + - questionservice ports: - "8000:8000" networks: - mynetwork environment: + QUESTION_SERVICE_URL: http://questionservice:8003 AUTH_SERVICE_URL: http://authservice:8002 USER_SERVICE_URL: http://userservice:8001 diff --git a/questions/.dockerignore b/questionservice/.dockerignore similarity index 100% rename from questions/.dockerignore rename to questionservice/.dockerignore diff --git a/questions/Dockerfile b/questionservice/Dockerfile similarity index 100% rename from questions/Dockerfile rename to questionservice/Dockerfile diff --git a/questions/data/literatura.json b/questionservice/data/literatura.json similarity index 100% rename from questions/data/literatura.json rename to questionservice/data/literatura.json diff --git a/questions/data/tematicas.json b/questionservice/data/tematicas.json similarity index 100% rename from questions/data/tematicas.json rename to questionservice/data/tematicas.json diff --git a/questions/package-lock.json b/questionservice/package-lock.json similarity index 100% rename from questions/package-lock.json rename to questionservice/package-lock.json diff --git a/questions/package.json b/questionservice/package.json similarity index 100% rename from questions/package.json rename to questionservice/package.json diff --git a/questions/question-service.js b/questionservice/question-service.js similarity index 100% rename from questions/question-service.js rename to questionservice/question-service.js diff --git a/questions/questionGen/GeneratorChooser.js b/questionservice/questionGen/GeneratorChooser.js similarity index 100% rename from questions/questionGen/GeneratorChooser.js rename to questionservice/questionGen/GeneratorChooser.js diff --git a/questions/questionGen/GenericGenerator.js b/questionservice/questionGen/GenericGenerator.js similarity index 100% rename from questions/questionGen/GenericGenerator.js rename to questionservice/questionGen/GenericGenerator.js