backend bottleneck-fix-try #33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy the websocket server | |
| on: | |
| push: | |
| branches: [ main ] | |
| env: | |
| IMAGE_NAME: ansh7845/excalidraw-websocket | |
| DOMAIN: excalidraw.anshtyagi.me | |
| DROPLET_IP: 142.93.223.72 | |
| BACKEND_URL: http://142.93.223.72:3001 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the code | |
| uses: actions/checkout@v2 | |
| - name: Docker login | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| file: ./docker/docker.websocket | |
| build-args: | | |
| REACT_APP_BACKEND_URL=${{ env.BACKEND_URL }} | |
| push: true | |
| tags: ${{ env.IMAGE_NAME }}:${{ github.sha }} | |
| - name: Deploy to the VM | |
| run: | | |
| echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/ssh_key | |
| chmod 600 ~/ssh_key | |
| ssh -o StrictHostKeyChecking=no -i ~/ssh_key root@${{ env.DROPLET_IP }} -t " | |
| docker stop excalidraw-websocket || true | |
| docker rm excalidraw-websocket || true | |
| docker run --name excalidraw-websocket -d -p 8081:8081 \ | |
| -e REACT_APP_BACKEND_URL=${{ env.BACKEND_URL }} \ | |
| -e DATABASE_URL='${{ secrets.DATABASE_URL }}' \ | |
| ${{ env.IMAGE_NAME }}:${{ github.sha }} | |
| " |