diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 717777f..a78134a 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -58,10 +58,20 @@ jobs: backend: image: harbor.galpodlipnik.com/chat-app/backend:latest restart: always - env_file: - - ./.env + # Instead of env_file, define the environment variables directly + environment: + - NODE_ENV=production + - PORT=3000 + - CORS_ORIGIN=http://localhost:5173 + - DATABASE_URL=${DATABASE_URL} + - JWT_SECRET=${JWT_SECRET} networks: - chat-network + healthcheck: + test: ["CMD", "wget", "-qO-", "http://localhost:3000/health"] + interval: 10s + timeout: 5s + retries: 5 frontend: image: harbor.galpodlipnik.com/chat-app/frontend:latest @@ -69,14 +79,15 @@ jobs: ports: - "5173:80" depends_on: - - backend + backend: + condition: service_healthy networks: - chat-network networks: chat-network: driver: bridge - EOL + EOL - name: Deploy with SSH uses: appleboy/ssh-action@master @@ -112,6 +123,10 @@ jobs: # Login to Harbor registry echo "${{ secrets.HARBOR_PASSWORD }}" | docker login harbor.galpodlipnik.com -u "${{ secrets.HARBOR_USERNAME }}" --password-stdin + + export DATABASE_URL=${{ secrets.DATABASE_URL }} + export JWT_SECRET=${{ secrets.JWT_SECRET }} + docker-compose up -d # Pull latest images and deploy docker compose pull diff --git a/backend/Dockerfile b/backend/Dockerfile index a49912a..1c11ff5 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -10,5 +10,4 @@ COPY . . RUN npm run db:generate RUN npm run build -EXPOSE 3000 -CMD ["npm", "start"] \ No newline at end of file +CMD ["node", "dist/index.js"] \ No newline at end of file