From 5853f3e86d0fe012452a2868c9cfdb1840b020ad Mon Sep 17 00:00:00 2001 From: Anyer Date: Tue, 27 May 2025 19:07:36 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Dockerfile=20per=20a=20producci=C3=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 590bf06..3018e17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,21 @@ -FROM node:20 +# Etapa 1: build del frontend +FROM node:20 AS build WORKDIR /app - COPY package*.json ./ RUN npm install - COPY . . +RUN npm run build + +# Etapa 2: nginx per servir estร tics +FROM nginx:alpine + +# Copiem el build al directori de nginx +COPY --from=build /app/dist /usr/share/nginx/html -ENV HOST=0.0.0.0 +# Opcional: custom nginx.conf si cal +# COPY nginx.conf /etc/nginx/conf.d/default.conf -EXPOSE 3000 +EXPOSE 80 -CMD ["npm", "run", "start"] \ No newline at end of file +CMD ["nginx", "-g", "daemon off;"] From ce25a90e3e1d8315bc84f7000986cd64db34ac28 Mon Sep 17 00:00:00 2001 From: Anyer Date: Tue, 27 May 2025 19:43:19 +0200 Subject: [PATCH 2/5] . --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3018e17..690d4fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN npm run build FROM nginx:alpine # Copiem el build al directori de nginx -COPY --from=build /app/dist /usr/share/nginx/html +COPY --from=build /app/build /usr/share/nginx/html # Opcional: custom nginx.conf si cal # COPY nginx.conf /etc/nginx/conf.d/default.conf From b61703e8bc7fc0b076945240e203741402d7e467 Mon Sep 17 00:00:00 2001 From: Anyer Date: Tue, 27 May 2025 20:09:00 +0200 Subject: [PATCH 3/5] . --- src/api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api.js b/src/api.js index 9847572..0b7703e 100644 --- a/src/api.js +++ b/src/api.js @@ -7,7 +7,7 @@ const isLocalhost = window.location.hostname === 'localhost' || const baseURL = isLocalhost ? 'http://127.0.0.1:8000/' - : 'http://187.33.149.121/'; + : 'http://187.33.149.121:8000/'; const api = axios.create({ baseURL, From 6f297e6126607dcca582d390a3069f90c1cb9533 Mon Sep 17 00:00:00 2001 From: Anyer Date: Tue, 27 May 2025 20:17:02 +0200 Subject: [PATCH 4/5] . --- .github/workflows/deploy.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b680c89..e092dca 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: ํบ€ Deploy Frontend to Server +name: ๐Ÿš€ Deploy Full Stack to Server on: push: @@ -10,11 +10,11 @@ jobs: runs-on: ubuntu-latest steps: - - name: ํด Set up SSH + - name: ๐Ÿ”‘ Set up SSH uses: webfactory/ssh-agent@v0.7.0 with: ssh-private-key: ${{ secrets.DEPLOY_KEY }} - - name: ํบ€ Deploy via SSH + - name: ๐Ÿš€ Deploy via SSH run: | - ssh -o StrictHostKeyChecking=no root@187.33.149.121 '/root/update-frontend.sh' + ssh -o StrictHostKeyChecking=no root@187.33.149.121 '/root/start.sh' From f86f2c5e2e765a3927d1670d31e4a10813a59876 Mon Sep 17 00:00:00 2001 From: Anyer Date: Tue, 27 May 2025 20:20:16 +0200 Subject: [PATCH 5/5] . --- Dockerfile | 1 + nginx.conf | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 690d4fd..a2ec557 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ FROM nginx:alpine # Copiem el build al directori de nginx COPY --from=build /app/build /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf # Opcional: custom nginx.conf si cal # COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..bb3f608 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,11 @@ +server { + listen 80; + server_name _; + + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri /index.html; + } +}