diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0882305..ade58c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -163,6 +163,7 @@ jobs: needs: [e2e-tests] steps: - uses: actions/checkout@v4 + - run: echo "NODE_ENV='production'" > gatewayservice/.env - name: Update OpenAPI configuration run: | DEPLOY_HOST=${{ secrets.DEPLOY_HOST }} @@ -189,12 +190,6 @@ jobs: ] steps: - name: Deploy over SSH - env: - ORIGIN_URL: ${{ env.ORIGIN_URL }} - AUTH_SERVICE_URL: ${{ env.AUTH_SERVICE_URL }} - USER_SERVICE_URL: ${{ env.USER_SERVICE_URL }} - QUESTION_SERVICE_URL: ${{ env.QUESTION_SERVICE_URL }} - STAT_SERVICE_URL: ${{ env.STAT_SERVICE_URL }} uses: fifsky/ssh-action@master with: host: ${{ secrets.DEPLOY_HOST }} @@ -202,10 +197,13 @@ jobs: key: ${{ secrets.DEPLOY_KEY }} command: | wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/docker-compose.yml -O docker-compose.yml - echo "ORIGIN_URL=${{ env.ORIGIN_URL }}" >> .env - echo "AUTH_SERVICE_URL=${{ env.AUTH_SERVICE_URL }}" >> .env - echo "USER_SERVICE_URL=${{ env.USER_SERVICE_URL }}" >> .env - echo "QUESTION_SERVICE_URL=${{ env.QUESTION_SERVICE_URL }}" >> .env - echo "STAT_SERVICE_URL=${{ env.STAT_SERVICE_URL }}" >> .env + wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/.env -O .env + mkdir -p errors + wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/errors/customErrors.js -O errors/customErrors.js + mkdir -p middleware + wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/middleware/auth-middleware.js -O middleware/auth-middleware.js + mkdir -p utils + wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/utils/tokenUtils.js -O utils/tokenUtils.js + wget https://raw.githubusercontent.com/arquisoft/wiq_7/master/utils/passwordUtils.js -O utils/passwordUtils.js docker compose --profile prod down docker compose --profile prod up -d --pull always diff --git a/docker-compose.yml b/docker-compose.yml index 8df1930..0327967 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -97,7 +97,7 @@ services: networks: - mynetwork environment: - ORIGIN_URL: http://localhost:3000 + ORIGIN_URL: http://4.233.148.160:3000 AUTH_SERVICE_URL: http://authservice:8002 USER_SERVICE_URL: http://userservice:8001 QUESTION_SERVICE_URL: http://questionservice:8003 diff --git a/gatewayservice/.env b/gatewayservice/.env index c315a36..254a9ea 100644 --- a/gatewayservice/.env +++ b/gatewayservice/.env @@ -1 +1 @@ -NODE_ENV === 'development' \ No newline at end of file +NODE_ENV = 'development' \ No newline at end of file diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index 363284e..b833981 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -1,6 +1,7 @@ import express from 'express'; import axios from 'axios'; import cors from 'cors'; +import dotenv from 'dotenv'; import promBundle from 'express-prom-bundle'; // Libraries required for OpenAPI-Swagger import swaggerUi from 'swagger-ui-express'; @@ -14,8 +15,17 @@ if (process.env.NODE_ENV === 'development') { const app = express(); const port = 8000; +dotenv.config(); + +let originUrl = process.env.ORIGIN_URL || 'http://localhost:3000'; +if (process.env.NODE_ENV === 'development') { + console.log('Using development origin URL'); + originUrl = 'http://localhost:3000'; +} + +console.log('NODE_ENVL'); +console.log(process.env.NODE_ENV); -const originUrl = process.env.ORIGIN_URL || 'http://localhost:3000'; const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002'; const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001'; const questionServiceUrl = diff --git a/gatewayservice/package-lock.json b/gatewayservice/package-lock.json index 8ee55b6..460c35d 100644 --- a/gatewayservice/package-lock.json +++ b/gatewayservice/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "axios": "^1.6.5", "cors": "^2.8.5", + "dotenv": "^16.4.7", "express": "^4.18.2", "express-openapi": "^12.1.3", "express-prom-bundle": "^7.0.0", @@ -1793,6 +1794,18 @@ "esprima": "^4.0.0" } }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", diff --git a/gatewayservice/package.json b/gatewayservice/package.json index d69470c..c97d207 100644 --- a/gatewayservice/package.json +++ b/gatewayservice/package.json @@ -24,6 +24,7 @@ "dependencies": { "axios": "^1.6.5", "cors": "^2.8.5", + "dotenv": "^16.4.7", "express": "^4.18.2", "express-openapi": "^12.1.3", "express-prom-bundle": "^7.0.0",