Skip to content

Commit

Permalink
chore: update deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
aseerkt committed Aug 9, 2024
1 parent 98ac509 commit da1cb9b
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 22 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/ec2-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ jobs:
run: pnpm i

- name: Build packages
env:
VITE_BACKEND_URL: https://${{ secrets.APP_DOMAIN }}
run: pnpm build

- name: Upload build files
Expand All @@ -53,8 +55,19 @@ jobs:
name: mchat_build

- name: Move static files
run: sudo mv web/dist /var/www/html
run: |
sudo rm -rf /var/www/html/*
sudo mv web/dist/* /var/www/html/
sudo rm -rf web/dist
- name: Reload caddy service
run: |
sudo systemctl reload caddy
# - name: Set server env file
# run:
# cd server && cp .env.example .env

- name: Restart application
run: pm2 restart mchat

Expand Down
3 changes: 2 additions & 1 deletion infra/ec2/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mchat.aseerkt.com {
root * /var/www/html
encode zstd gzip
file_server /dist/*
file_server
reverse_proxy /api/* 127.0.0.1:5000
}
5 changes: 0 additions & 5 deletions infra/ec2/Makefile

This file was deleted.

13 changes: 0 additions & 13 deletions infra/ec2/docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,3 @@ services:
interval: 30s
timeout: 10s
retries: 5

caddy:
image: caddy:2.8.4-alpine
container_name: mchat_caddy
restart: unless-stopped
cap_add:
- NET_ADMIN
ports:
- '80:80'
- '443:443'
- '443:443/udp'
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
1 change: 1 addition & 0 deletions infra/ec2/docker-down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo docker compose -f docker-compose.prod.yml down
1 change: 1 addition & 0 deletions infra/ec2/docker-up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo docker compose -f docker-compose.prod.yml up -d
22 changes: 20 additions & 2 deletions infra/ec2/install.sh → infra/ec2/init.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# INSTALL NODE.JS
## INSTALL NODE.JS

# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Expand All @@ -12,9 +12,11 @@ node -v # should print `v20.16.0`
# verifies the right npm version is in the environment
npm -v # should print `10.8.1`

## INSTALL PM2

npm i -g pm2

# INSTALL DOCKER
## INSTALL DOCKER

# Add Docker's official GPG key:
sudo apt-get update
Expand All @@ -31,3 +33,19 @@ echo \
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

## INSTAL CADDY

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

sudo mkdir /srv

cp ./Caddyfile /etc/caddy/Caddyfile

./reload-caddy.sh

./docker-up.sh
1 change: 1 addition & 0 deletions infra/ec2/reload-caddy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo systemctl reload caddy

0 comments on commit da1cb9b

Please sign in to comment.