diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f221668..22c0bf2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,24 +8,29 @@ jobs: docker-push-webapp: name: Push webapp Docker Image to GitHub Packages runs-on: ubuntu-latest - permissions: contents: read packages: write steps: - uses: actions/checkout@v4 + + - name: Create .env file + run: echo "REACT_APP_API_ENDPOINT=http://${{ secrets.DEPLOY_HOST }}:8000" > webapp/.env + - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@v5 env: - API_URI: http://${{ secrets.DEPLOY_HOST }}:8000 + REACT_APP_API_ENDPOINT: http://${{ secrets.DEPLOY_HOST }}:8000 + teamname: wiq_en3a with: name: arquisoft/wiq_en3a/webapp username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io workdir: webapp - buildargs: API_URI - docker-push-wikidataservice: + buildargs: | + REACT_APP_API_ENDPOINT + docker-push-wikidata-service: name: Push wikidata Docker Image to GitHub Packages runs-on: ubuntu-latest permissions: @@ -76,7 +81,7 @@ jobs: deploy: name: Deploy over SSH runs-on: ubuntu-latest - needs: [docker-push-userservice,docker-push-gatewayservice,docker-push-webapp, docker-push-wikidataservice] + needs: [docker-push-userservice,docker-push-gatewayservice,docker-push-webapp, docker-push-wikidata-service] steps: - name: Deploy over SSH uses: fifsky/ssh-action@master diff --git a/docker-compose.yml b/docker-compose.yml index 7fa53d8..d09bc15 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -57,11 +57,14 @@ services: container_name: webapp-${teamname:-defaultASW} image: ghcr.io/arquisoft/wiq_en3a/webapp:latest profiles: ["dev", "prod"] - build: ./webapp - depends_on: - - gatewayservice + build: + args: + REACT_APP_API_ENDPOINT: ${API_URI} + context: ./webapp + environment: + - REACT_APP_API_ENDPOINT=${API_URI} ports: - - "3000:3000" + - "3000:3000" prometheus: image: prom/prometheus diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index bd4fea3..241eec9 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -21,7 +21,7 @@ app.get('/health', (_req, res) => { res.json({ status: 'OK' }); }); -app.post(userServiceUrl + '/login', async (req, res) => { +app.post('/login', async (req, res) => { try { // Forward the login request to the authentication service const authResponse = await axios.post(userServiceUrl + '/auth/login', req.body); @@ -31,7 +31,7 @@ app.post(userServiceUrl + '/login', async (req, res) => { } }); -app.post(userServiceUrl + '/adduser', async (req, res) => { +app.post('/adduser', async (req, res) => { try { // Forward the add user request to the user service const userResponse = await axios.post(userServiceUrl + '/user/adduser', req.body); @@ -51,7 +51,7 @@ app.post('/edituser', async (req, res) => { } }); -app.get(wikidataServiceUrl + '/WikiData/GetCapitalsQuestions', async (_req, res) => { +app.get('/WikiData/GetCapitalsQuestions', async (_req, res) => { try { // Forward the edit user request to the user service const wikiResponse = await axios.get(wikidataServiceUrl+'/WikiData/GetCapitalsQuestions');