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' diff --git a/Dockerfile b/Dockerfile index 590bf06..a2ec557 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,22 @@ -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/build /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf -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;"] 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; + } +} 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,