Skip to content

Commit

Permalink
se agrego en el release el pasar como buildargs el valor de la ip de …
Browse files Browse the repository at this point in the history
…la maquina , en el compose se agrego que webapp reciba el valor y luego lo guarde como enviroment, agregado tambien en la urls de login y add un http que da error en caso de que no se cargue bien
  • Loading branch information
bidof committed Feb 29, 2024
1 parent 791a596 commit 9d6982a
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 53 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"
2 changes: 1 addition & 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,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
Expand Down
74 changes: 34 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
11 changes: 6 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -59,7 +59,6 @@ services:

questionservice:
container_name: questionservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_0/userservice:latest
build: ./questionservice
ports:
- "8003:8003"
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions webapp/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.env
coverage
2 changes: 1 addition & 1 deletion webapp/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_API_ENDPOINT=
REACT_APP_API_ENDPOINT=http://localhost:8000
5 changes: 2 additions & 3 deletions webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/AddUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9d6982a

Please sign in to comment.