Skip to content

Commit

Permalink
Merge branch 'david' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bidof committed Mar 7, 2024
2 parents fc73c0d + ca429e2 commit e17dba7
Show file tree
Hide file tree
Showing 31 changed files with 1,633 additions and 265 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
teamname="wiq_es04c"
teamname="wiq_es04c"
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master
- releases
pull_request:
types: [opened, synchronize, reopened]
jobs:
Expand All @@ -18,8 +19,8 @@ jobs:
- run: npm --prefix users/authservice ci
- run: npm --prefix users/userservice ci
- run: npm --prefix gatewayservice ci
- run: npm --prefix questionsservice ci # Agrega la tarea para questionsservice
- 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
Expand Down
59 changes: 28 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
name: Deploy on release

on:
push:
branches:
-master
-releases
release:
types: [published]

jobs:
unit-tests:
Expand Down Expand Up @@ -53,16 +51,34 @@ jobs:
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
API_URI: http://${{ secrets.DEPLOY_HOST || 'localhost' }}:8000


API_URI: http://${{ secrets.DEPLOY_HOST }}:8000
with:
name: arquisoft/wiq_es04c/webapp
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: webapp
buildargs: API_URI
docker-push-questionservice:
name: Push question 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_es04c/questionservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: ./questionservice



docker-push-authservice:
name: Push auth service Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand Down Expand Up @@ -113,29 +129,11 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: ./gatewayservice
docker-push-questionservice:
name: Push question 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_es04c/questionservice
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
workdir: ./questionservice

workdir: gatewayservice
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp,docker-push-questionservice]
needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
Expand All @@ -144,8 +142,7 @@ jobs:
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
command: |
wget https://raw.githubusercontent.com/arquisoft/wiq_es04c/releases/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es04c/releases/.env -O .env
git clone -b releases https://github.com/Arquisoft/wiq_es04c.git
wget https://raw.githubusercontent.com/arquisoft/wiq_es04c/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es04c/master/.env -O .env
docker compose --profile prod down
docker compose --profile prod up -d
docker compose --profile prod up -d
7 changes: 4 additions & 3 deletions api_interfaces/api_questionservice.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ devuelve json -> {question: string, answers: answer[]}
answer: {answer: string, correct: boolean}

EJEMPLO
const example_data = {question: 'pregunta ejemplo', answers: [
const example_data = {question: 'pregunta ejemplo', respuesta: [
{answer: 'respuesta correcta', correct: true},
{answer: 'respuesta incorrecta1', correct: false},
{answer: 'respuesta incorrecta2', correct: false},
{answer: 'respuesta incorrecta3', correct: false}
]};
{answer: 'respuesta incorrecta3', correct: false}],
questionCategory: 'geografia'
};
59 changes: 46 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
mongodb:
container_name: mongodb-${teamname:-defaultASW}
container_name: mongodb-${teamname:-wiq_es04c}
image: mongo
profiles: ["dev", "prod"]
volumes:
Expand All @@ -10,10 +10,34 @@ services:
- "27017:27017"
networks:
- mynetwork
# Servicio de MySQL no se mete en el release te bajas la ultima imagen
questionservice-mysql:
image: mysql:latest
container_name: questionservice-mysql-${teamname:-wiq_es04c}
environment:
MYSQL_USER: bidof
MYSQL_PASSWORD: admin
MYSQL_ROOT_PASSWORD: admin
MYSQL_DATABASE: questions_db
MYSQL_CHARSET: utf8mb4
MYSQL_COLLATION: utf8mb4_unicode_ci
DB_PORT: 3306

ports:
- "3306:3306"
volumes:
- mysql-data:/var/lib/mysql
#montar en el directorio de mysql el archivo schema que esta en questionservice/database para que lo tenga el contendor y lo pueda ejecutar
#create_db es true
- ./questionservice/database/:/docker-entrypoint-initdb.d
networks:
- mynetwork
expose:
- "3306"

authservice:
container_name: authservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_0/authservice:latest
container_name: authservice-${teamname:-wiq_es04c}
image: ghcr.io/arquisoft/${teamname:-wiq_es04c}/authservice:latest
profiles: ["dev", "prod"]
build: ./users/authservice
depends_on:
Expand All @@ -26,8 +50,8 @@ services:
MONGODB_URI: mongodb://mongodb:27017/userdb

userservice:
container_name: userservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_0/userservice:latest
container_name: userservice-${teamname:-wiq_es04c}
image: ghcr.io/arquisoft/${teamname:-wiq_es04c}/userservice:latest
profiles: ["dev", "prod"]
build: ./users/userservice
depends_on:
Expand All @@ -40,8 +64,8 @@ services:
MONGODB_URI: mongodb://mongodb:27017/userdb

gatewayservice:
container_name: gatewayservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_0/gatewayservice:latest
container_name: gatewayservice-${teamname:-wiq_es04c}
image: ghcr.io/arquisoft/${teamname:-wiq_es04c}/gatewayservice:latest
profiles: ["dev", "prod"]
build: ./gatewayservice
depends_on:
Expand All @@ -59,26 +83,33 @@ services:


questionservice:
container_name: questionservice-${teamname:-defaultASW}
build: ./questionservice
container_name: questionservice-${teamname:-wiq_es04c}
build: questionservice
depends_on:
- questionservice-mysql
ports:
- "8003:8003"
networks:
- mynetwork
environment:
DB_HOST: questionservice-mysql


webapp:
container_name: webapp-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_0/webapp:latest
container_name: webapp-${teamname:-wiq_es04c}
image: ghcr.io/arquisoft/${teamname:-wiq_es04c}/webapp:latest
profiles: ["dev", "prod"]
build: ./webapp
depends_on:
- gatewayservice
ports:
- "3000:3000"
environment:
- API_URI=${API_URI}

prometheus:
image: prom/prometheus
container_name: prometheus-${teamname:-defaultASW}
container_name: prometheus-${teamname:-wiq_es04c}
profiles: ["dev"]
networks:
- mynetwork
Expand All @@ -92,7 +123,7 @@ services:

grafana:
image: grafana/grafana
container_name: grafana-${teamname:-defaultASW}
container_name: grafana-${teamname:-wiq_es04c}
profiles: ["dev"]
networks:
- mynetwork
Expand All @@ -114,6 +145,8 @@ volumes:
mongodb_data:
prometheus_data:
grafana_data:
mysql-data:


networks:
mynetwork:
Expand Down
16 changes: 13 additions & 3 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const express = require('express');
const axios = require('axios');
const cors = require('cors');
const promBundle = require('express-prom-bundle');

const app = express();
const port = 8000;

Expand Down Expand Up @@ -51,11 +50,22 @@ app.get('/getquestion', async(req,res)=> {
res.json(response.data);

} catch(error) {
res.status(error.response.status).json({ error: error.response.data.error });
if (error.response) {
res.status(error.response.status).json({ error: error.response.data.error });
} else {
res.status(500).json({ error: 'An unexpected error occurred' });
}
}
});


app.get('/generateQuestions', async(req,res)=> {
try{

} catch(error) {
res.status(error.response.status).json({ error: error.response.data.error });
}

});
// Start the gateway service
const server = app.listen(port, () => {
console.log(`Gateway Service listening at http://localhost:${port}`);
Expand Down
6 changes: 3 additions & 3 deletions gatewayservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/arquisoft/wiq_0.git"
"url": "git+https://github.com/arquisoft/wiq_es04c.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/arquisoft/wiq_0/issues"
"url": "https://github.com/arquisoft/wiq_es04c/issues"
},
"homepage": "https://github.com/arquisoft/wiq_0#readme",
"homepage": "https://github.com/arquisoft/wiq_es04c#readme",
"dependencies": {
"axios": "^1.6.5",
"cors": "^2.8.5",
Expand Down
Loading

0 comments on commit e17dba7

Please sign in to comment.