diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b493573..3b2508d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -38,6 +38,19 @@ jobs: git clone https://github.com/Trycatch-tv/ValidadorBootcamp-backend /home/${{ secrets.EC2_USER }}/app cd /home/${{ secrets.EC2_USER }}/app + + # Crear un archivo .env con las variables de entorno necesarias + echo "DATABASE_HOST=${{secrets.DATABASE_NAME}}" > .env + echo "DATABASE_PORT=${{secrets.DATABASE_PORT}}" >> .env + echo "DATABASE_USER=${{secrets.DATABASE_USER}}" >> .env + echo "DATABASE_PASSWORD=${{secrets.DATABASE_PASSWORD}}" >> .env + echo "DATABASE_NAME=${{secrets.DATABASE_NAME}}" >> .env + echo "FILE_SERVICE_URL=${{secrets.FILE_SERVICE_URL}}" >> .env + echo "REVIEW_SERVICE_URL=${{secrets.REVIEW_SERVICE_URL}}" >> .env + echo "NODE_ENV=${{secrets.NODE_ENV}}" >> .env + echo "POSTGRES_USER=${{secrets.POSTGRES_USER}}" >> .env + echo "POSTGRES_PASSWORD=${{secrets.POSTGRES_PASSWORD}}" >> .env + echo "POSTGRES_DB=${{secrets.POSTGRES_DB}}" >> .env # Actualizar la imagen del servicio backend y reiniciarlo sin afectar db docker-compose down diff --git a/docker-compose.yml b/docker-compose.yml index 066bdc5..936a02f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,10 +4,12 @@ services: db: image: postgres:14.2-alpine restart: always + env_file: + - .env environment: - - POSTGRES_DB=validador_bootcamps - - POSTGRES_USER=admin - - POSTGRES_PASSWORD=trycatch_tv23 + - POSTGRES_DB=${POSTGRES_DB} + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} volumes: - db-data:/var/lib/postgresql/data networks: @@ -18,15 +20,17 @@ services: backend: build: . container_name: backend + env_file: + - .env environment: - - DATABASE_HOST=db - - DATABASE_PORT=5432 - - DATABASE_USER=admin - - DATABASE_PASSWORD=trycatch_tv23 - - DATABASE_NAME=validador_bootcamps - - FILE_SERVICE_URL=http://localhost:3000/files - - REVIEW_SERVICE_URL=http://localhost:3000/reviews - - NODE_ENV=dev + - DATABASE_HOST=${DATABASE_HOST} + - DATABASE_PORT=${DATABASE_PORT} + - DATABASE_USER=${DATABASE_USER} + - DATABASE_PASSWORD=${DATABASE_PASSWORD} + - DATABASE_NAME=${DATABASE_NAME} + - FILE_SERVICE_URL=${FILE_SERVICE_URL} + - REVIEW_SERVICE_URL=${REVIEW_SERVICE_URL} + - NODE_ENV=${NODE_ENV} networks: - vnet-backend depends_on: