diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..c42da7a --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,21 @@ +name: Deploy to VM Prod + +on: + push: + branches: + - main # déclenche le déploiement quand tu push sur main + +jobs: + deploy: + runs-on: self-hosted # ton runner VM code-server + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Deploy to production + run: | + ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} " + cd ${{ secrets.DEPLOY_PATH }} || exit 1 + git pull origin main + docker compose up -d --build + " diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a7bd3a2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + app: + image: node:18 + working_dir: /usr/src/app + volumes: + - ./:/usr/src/app + ports: + - "3000:3000" + environment: + - NODE_ENV=production + - PORT=3000 + command: sh -c "npm install && npm start" \ No newline at end of file