From 351b65ebd3a4a58b9cf3f0201941e0881690ba0e Mon Sep 17 00:00:00 2001 From: bidof Date: Mon, 11 Mar 2024 19:41:10 +0100 Subject: [PATCH] intento 3 de arreglar despliegue --- .github/workflows/release.yml | 5 ++--- webapp/Dockerfile | 9 +++++---- webapp/src/components/adduser/AddUser.js | 2 +- webapp/src/components/login/Login.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c0a9866..0b2620b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -51,15 +51,14 @@ jobs: - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@v5 env: - DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} - DEPLOY_PORT: 8000 + REACT_APP_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: DEPLOY_HOST,DEPLOY_PORT + buildargs: REACT_APP_API_URI docker-push-questionservice: name: Push question service Docker Image to GitHub Packages runs-on: ubuntu-latest diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 5da6151..51abaa6 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -6,11 +6,12 @@ WORKDIR /app #Install the dependencies RUN npm install -#tomar los valores de las variables de entorno del buildargs -ARG DEPLOY_HOST -ARG DEPLOY_PORT +# Take the values of the environment variables from the buildargs +ARG REACT_APP_API_URI + +# Set the environment variable +ENV REACT_APP_API_URI=$REACT_APP_API_URI -ENV API_URI=http://${DEPLOY_HOST}:${DEPLOY_PORT} #Create an optimized version of the webapp RUN npm run build diff --git a/webapp/src/components/adduser/AddUser.js b/webapp/src/components/adduser/AddUser.js index c94ce9b..db0a2e7 100644 --- a/webapp/src/components/adduser/AddUser.js +++ b/webapp/src/components/adduser/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.API_URI || 'http://localhost:8000'; +const apiEndpoint = process.env.REACT_APP_API_URI ||'http://localhost:8000'; const AddUser = () => { const [username, setUsername] = useState(''); diff --git a/webapp/src/components/login/Login.js b/webapp/src/components/login/Login.js index 3c1a854..95a135e 100644 --- a/webapp/src/components/login/Login.js +++ b/webapp/src/components/login/Login.js @@ -19,7 +19,7 @@ const Login = () => { const [createdAt, setCreatedAt] = useState(''); const [openSnackbar, setOpenSnackbar] = useState(false); - const apiEndpoint = process.env.API_URI ||'http://localhost:8000'; + const apiEndpoint = process.env.REACT_APP_API_URI ||'http://localhost:8000'; useEffect(() => { if (loginSuccess) {