Skip to content

chore(@repo/env-config): add tsup to build the project #173

chore(@repo/env-config): add tsup to build the project

chore(@repo/env-config): add tsup to build the project #173

Workflow file for this run

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 "127.0.0.1:4000:4000" -p "127.0.0.1:4001:4001" --name bolhadev-chat --restart unless-stopped --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
docker image prune -f