feat(server): refactor from socket.io to ws implementation #68
This file contains 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 to EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: Production | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: Build and push Docker image | |
run: | | |
docker compose build | |
docker tag brunoroh/bolhadev-chat:latest ${{ vars.DOCKER_REPO}}/bolhadev-chat:latest | |
docker tag brunoroh/bolhadev-nginx:latest ${{ vars.DOCKER_REPO}}/bolhadev-nginx:latest | |
docker login -u ${{ vars.DOCKER_USERNAME }} -p ${{secrets.DOCKER_TOKEN}} | |
docker push ${{ vars.DOCKER_REPO}}/bolhadev-chat:latest | |
docker push ${{ vars.DOCKER_REPO}}/bolhadev-nginx:latest | |
- name: SSH into EC2 instance and deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
key: ${{ secrets.EC2_SSH_KEY }} | |
script: | | |
sudo docker pull ${{ vars.DOCKER_REPO }}/bolhadev-chat:latest | |
sudo docker pull ${{ vars.DOCKER_REPO }}/bolhadev-nginx:latest | |
sudo docker stop bolhadev-nginx || true | |
sudo docker stop bolhadev-chat || true | |
sudo docker rm bolhadev-nginx || true | |
sudo docker rm bolhadev-chat || true | |
sudo docker run -d -p 4000:4000 -p 4001:4001 --name bolhadev-chat --network internal ${{ vars.DOCKER_REPO }}/bolhadev-chat:latest | |
sudo docker run -d -p 80:80 -p 443:443 \ | |
--name bolhadev-nginx \ | |
-v /var/www/certbot:/var/www/certbot \ | |
-v /etc/letsencrypt/ssl/fullchain.pem:/etc/nginx/ssl/fullchain.pem \ | |
-v /etc/letsencrypt/ssl/privkey.pem:/etc/nginx/ssl/privkey.pem \ | |
--network internal \ | |
${{ vars.DOCKER_REPO }}/bolhadev-nginx:latest | |
sudo docker image prune |