Skip to content

Commit

Permalink
Madrugada de CI/CD (#18)
Browse files Browse the repository at this point in the history
* KAN-27 Feature: redef del paso 1 prod

* KAN-27 Fix Errores en Dockerfile y Feature segunda etapa despliegue

* KAN-27 Refactor: CD en un solo archivo

* KAN-27 Fix checkout on prod api server y nueva action de firebase deploy

* KAN-27 Detectar error de permiso docker y segundo intento de firebase deploy

* nuevos permisos

* Por qué lee el docker-compose de dev en vez de el generico?
  • Loading branch information
logos914 authored Sep 10, 2024
1 parent b569258 commit 6698d1e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 31 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/api-deploy.yml

This file was deleted.

59 changes: 44 additions & 15 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ jobs:
runs-on: potus
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22


build-client:
runs-on: potus
needs: setup
steps:
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup dependencias de client
working-directory: ./client
run: npm install
Expand All @@ -37,6 +36,9 @@ jobs:
runs-on: potus
needs: setup
steps:
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup dependencias de admin
working-directory: ./admin
run: npm install
Expand All @@ -51,30 +53,57 @@ jobs:
steps:
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_NMS_DEVMASTER }}
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}"
projectId: nms-devmaster
channelId: live
target: web-client


deploy-admin:
runs-on: potus
needs: setup
needs: build-admin
steps:
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_NMS_DEVMASTER }}
projectId: nms-devmaster
target: web-admin
- uses: lowply/deploy-firebase@v0.0.5
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_PROJECT: nms-devmaster


build-server:
runs-on: potus
permissions:
contents: read
packages: write
needs: setup
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image BACKEND
run: docker build -t ghcr.io/devmasters2-0/tp-inicial-laboratorio/nms-server:latest -f ./backend/Dockerfile-prod ./backend

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image to GCR BACKEND
run: docker push ghcr.io/devmasters2-0/tp-inicial-laboratorio/nms-server:latest


deploy-server:
runs-on: lws01
needs: build-server
steps:
- uses: actions/checkout@v4
- name: Quien soy
run: whoami
- name: Bajar servicio anterior Intento 1
run: docker-compose -f docker-compose-prod.yml -p dm-nms down
- name: Bajar servicio anterior Intento 2
run: docker-compose -f docker-compose-prod.yml -p dm-nms down
- name: Desplegar en LWS
env:
EMAIL_SMTP_USER: ${{ secrets.EMAIL_SMTP_USER }}
EMAIL_SMTP_PASSWORD: ${{ secrets.EMAIL_SMTP_PASSWORD }}
EMAIL_SMTP_SERVER: ${{ secrets.EMAIL_SMTP_SERVER }}
TEST: "true"
run: docker-compose -f docker-compose-prod.yml -p dm-nms up -d
6 changes: 4 additions & 2 deletions backend/Dockerfile-prod
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ COPY package*.json ./
# Instalar las dependencias
RUN npm install

COPY . .


RUN npm run build

# Copiar el resto de los archivos de la aplicación
COPY . .


# Exponer el puerto en el que corre la aplicación
EXPOSE 3000
Expand Down
File renamed without changes.

0 comments on commit 6698d1e

Please sign in to comment.