diff --git a/.env b/.env index 8666014..4cc1526 100644 --- a/.env +++ b/.env @@ -1 +1 @@ -teamname="wiq_es04c" \ No newline at end of file +teamname="wiq_es04c" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b281041..b99a506 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,6 +3,7 @@ on: push: branches: - master + - releases pull_request: types: [opened, synchronize, reopened] jobs: @@ -18,7 +19,6 @@ 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 users/authservice test -- --coverage - run: npm --prefix users/userservice test -- --coverage diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f1d3d5..aa858d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,32 +40,45 @@ jobs: - run: npm --prefix webapp run build - run: npm --prefix webapp run test:e2e - docker-push-webapp: - name: Push webapp Docker Image to GitHub Packages + 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: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io + - 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-webapp: + name: Push webapp 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 + env: + API_URI: http://${{ secrets.DEPLOY_HOST }}:8000 + with: + name: arquisoft/wiq_es04c/webapp username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v2 - with: - context: ./webapp - push: true - tags: ghcr.io/arquisoft/wiq_es04c/webapp:latest - build-args: API_URI=http://${{ secrets.DEPLOY_HOST || 'localhost' }}:8000 - no-cache: true - + registry: ghcr.io + workdir: webapp + buildargs: API_URI=${{ env.API_URI }} + docker-push-authservice: name: Push auth service Docker Image to GitHub Packages runs-on: ubuntu-latest @@ -116,25 +129,7 @@ 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 @@ -149,6 +144,5 @@ jobs: 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 - docker compose --profile prod down - docker compose --profile prod up -d + docker compose down + docker compose --profile prod up -d \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index be34da5..669009b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,7 +13,7 @@ services: authservice: container_name: authservice-${teamname:-defaultASW} - image: ghcr.io/arquisoft/wiq_0/authservice:latest + image: ghcr.io/arquisoft/wiq_es04c/authservice:latest profiles: ["dev", "prod"] build: ./users/authservice depends_on: @@ -27,7 +27,7 @@ services: userservice: container_name: userservice-${teamname:-defaultASW} - image: ghcr.io/arquisoft/wiq_0/userservice:latest + image: ghcr.io/arquisoft/wiq_es04c/userservice:latest profiles: ["dev", "prod"] build: ./users/userservice depends_on: @@ -41,7 +41,7 @@ services: gatewayservice: container_name: gatewayservice-${teamname:-defaultASW} - image: ghcr.io/arquisoft/wiq_0/gatewayservice:latest + image: ghcr.io/arquisoft/wiq_es04c/gatewayservice:latest profiles: ["dev", "prod"] build: ./gatewayservice depends_on: @@ -59,7 +59,6 @@ services: questionservice: container_name: questionservice-${teamname:-defaultASW} - image: ghcr.io/arquisoft/wiq_0/userservice:latest build: ./questionservice ports: - "8003:8003" @@ -68,13 +67,15 @@ services: webapp: container_name: webapp-${teamname:-defaultASW} - image: ghcr.io/arquisoft/wiq_0/webapp:latest + image: ghcr.io/arquisoft/wiq_es04c/webapp:latest profiles: ["dev", "prod"] build: ./webapp depends_on: - gatewayservice ports: - "3000:3000" + environment: + - API_URI=${API_URI} prometheus: image: prom/prometheus diff --git a/webapp/.dockerignore b/webapp/.dockerignore index 3091757..cbb7231 100644 --- a/webapp/.dockerignore +++ b/webapp/.dockerignore @@ -1,2 +1,3 @@ node_modules +.env coverage \ No newline at end of file diff --git a/webapp/.env b/webapp/.env index 11fdc41..c810bde 100644 --- a/webapp/.env +++ b/webapp/.env @@ -1 +1 @@ -REACT_APP_API_ENDPOINT= \ No newline at end of file +REACT_APP_API_ENDPOINT=http://localhost:8000 \ No newline at end of file diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 85bd381..3cbad8b 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -6,9 +6,8 @@ WORKDIR /app #Install the dependencies RUN npm install -ARG API_URI -#recibe la url de releaase.yml o bien localhost si no la proporcionas -ENV REACT_APP_API_ENDPOINT=${API_URI} +ARG API_URI="http://localhost:8000" +ENV REACT_APP_API_ENDPOINT=$API_URI #Create an optimized version of the webapp RUN npm run build diff --git a/webapp/src/components/AddUser.js b/webapp/src/components/AddUser.js index e039a35..65f77ba 100644 --- a/webapp/src/components/AddUser.js +++ b/webapp/src/components/AddUser.js @@ -3,7 +3,7 @@ import React, { useState } from 'react'; import axios from 'axios'; import { Container, Typography, TextField, Button, Snackbar } from '@mui/material'; -const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; +const apiEndpoint = process.env.API_URI || 'http://error no se cargo bien la apiURI de docker'; const AddUser = () => { const [username, setUsername] = useState(''); diff --git a/webapp/src/components/Login.js b/webapp/src/components/Login.js index 5e7e3dc..8783111 100644 --- a/webapp/src/components/Login.js +++ b/webapp/src/components/Login.js @@ -11,7 +11,7 @@ const Login = () => { const [createdAt, setCreatedAt] = useState(''); const [openSnackbar, setOpenSnackbar] = useState(false); - const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; + const apiEndpoint = process.env.API_URI ||'http://Error no se cargo bien la apiURI de docker'; const loginUser = async () => { try {