From e2192c62bf395a78dd33e2e9de23a1bb7b532bdc Mon Sep 17 00:00:00 2001 From: Iago Souza Date: Tue, 12 Nov 2024 10:08:02 -0300 Subject: [PATCH 1/2] oper: rodando npm install com legacy-peer-deps --- package-lock.json | 20 -------------------- tupan/Dockerfile | 2 +- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4feb846..c884548 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,13 +4,9 @@ "requires": true, "packages": { "": { - "dependencies": { - "js-cookie": "^3.0.5" - }, "devDependencies": { "@commitlint/cli": "^19.4.1", "@commitlint/config-conventional": "^19.4.1", - "@types/js-cookie": "^3.0.6", "husky": "^9.1.5" } }, @@ -367,13 +363,6 @@ "@types/node": "*" } }, - "node_modules/@types/js-cookie": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.6.tgz", - "integrity": "sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/node": { "version": "22.5.4", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.4.tgz", @@ -955,15 +944,6 @@ "jiti": "bin/jiti.js" } }, - "node_modules/js-cookie": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz", - "integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==", - "license": "MIT", - "engines": { - "node": ">=14" - } - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", diff --git a/tupan/Dockerfile b/tupan/Dockerfile index 05e9cf7..4f24b46 100644 --- a/tupan/Dockerfile +++ b/tupan/Dockerfile @@ -4,7 +4,7 @@ FROM base AS deps RUN apk add --no-cache libc6-compat WORKDIR /app COPY package.json package-lock.json* ./ -RUN npm ci +RUN npm ci --legacy-peer-deps FROM base AS builder WORKDIR /app From 5b0748b1ee9a82a94584f7c9dccf71c45407b2e6 Mon Sep 17 00:00:00 2001 From: Iago Souza Date: Tue, 12 Nov 2024 10:38:03 -0300 Subject: [PATCH 2/2] oper: adicionando .env para pegar o ip do backend na aws --- .github/workflows/ec2deploy.yaml | 5 +++++ tupan/.gitignore | 1 + tupan/package-lock.json | 13 +++++++++++++ tupan/package.json | 1 + tupan/src/app/_api/index.ts | 5 ++++- 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ec2deploy.yaml b/.github/workflows/ec2deploy.yaml index 6ddc9f4..9f35e08 100644 --- a/.github/workflows/ec2deploy.yaml +++ b/.github/workflows/ec2deploy.yaml @@ -8,6 +8,7 @@ on: env: AWS_PRIVATE_KEY: ${{ secrets.KEYAWS }} EC2_IP: ${{ secrets.EC2_IP }} + BACKEND_PORT: ${{ secrets.BACKEND_PORT }} SSH_OPTIONS: '-o StrictHostKeyChecking=no -i key.pem ubuntu@${{ secrets.EC2_IP }}' jobs: @@ -51,6 +52,10 @@ jobs: run: | scp -o StrictHostKeyChecking=no -i key.pem -r ./tupan/ ubuntu@${{ env.EC2_IP }}:/home/ubuntu/tupan + - name: Create .env file + run: | + echo "BACKEND_URL=${{ env.EC2_IP }}:${{ env.BACKEND_PORT }}/" >> tupan/.env + - name: SSH into AWS and build Docker image run: | ssh ${{ env.SSH_OPTIONS }} 'cd /home/ubuntu/tupan/tupan && sudo docker build -t tupan-front .' diff --git a/tupan/.gitignore b/tupan/.gitignore index fd3dbb5..6530858 100644 --- a/tupan/.gitignore +++ b/tupan/.gitignore @@ -19,6 +19,7 @@ # misc .DS_Store *.pem +.env # debug npm-debug.log* diff --git a/tupan/package-lock.json b/tupan/package-lock.json index ea2c116..2d328bf 100644 --- a/tupan/package-lock.json +++ b/tupan/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@material-tailwind/react": "^2.1.10", "axios": "^1.7.7", + "dotenv": "^16.4.5", "flowbite": "^2.5.1", "highcharts": "^11.4.8", "js-cookie": "^3.0.5", @@ -4095,6 +4096,18 @@ "node": ">=12" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", diff --git a/tupan/package.json b/tupan/package.json index 2da8113..ffde6ae 100644 --- a/tupan/package.json +++ b/tupan/package.json @@ -19,6 +19,7 @@ "dependencies": { "@material-tailwind/react": "^2.1.10", "axios": "^1.7.7", + "dotenv": "^16.4.5", "flowbite": "^2.5.1", "highcharts": "^11.4.8", "js-cookie": "^3.0.5", diff --git a/tupan/src/app/_api/index.ts b/tupan/src/app/_api/index.ts index 514953e..a2c2a58 100644 --- a/tupan/src/app/_api/index.ts +++ b/tupan/src/app/_api/index.ts @@ -1 +1,4 @@ -export const api_route: string = 'http://localhost:8000/'; \ No newline at end of file +import * as dotenv from 'dotenv'; +dotenv.config(); + +export const api_route: string = process.env.BACKEND_URL || 'http://localhost:8000/';