Skip to content

Instantly share code, notes, and snippets.

@majudhu
Last active March 22, 2025 17:06
Show Gist options
  • Select an option

  • Save majudhu/1f96da9fb19541154bacba71e55fc75b to your computer and use it in GitHub Desktop.

Select an option

Save majudhu/1f96da9fb19541154bacba71e55fc75b to your computer and use it in GitHub Desktop.
[Unit]
Description=islego-web
After=network.target
[Service]
Type=simple
User=islego-web
ExecStart=/home/islego/.bun/bin/bun --bun run start
WorkingDirectory=/home/islego/islego-web
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
#!/bin/sh
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
APP="islego-web"
while read oldrev newrev ref
do
if [ "$ref" = "refs/heads/main" ];
then
sudo systemctl stop --force "$APP"
git --work-tree=.. checkout -f
cd ..
bun i --frozen-lockfile
bun --bun drizzle-kit migrate
bun --bun run build
sudo systemctl start "$APP"
fi
done
## setup
# ssh root@123.45.67.89
# apt update && apt upgrade -y && apt full-upgrade -y && apt autoremove -y && reboot
# apt install tmux git unzip
# adduser --disabled-password islego --add-extra-groups adm
# adduser --system --home ~islego/islego-web --no-create-home islego-web
# sudo -iu islego
# mkdir -m 700 .ssh
# vim .ssh/authorized_keys
# chmod 600 .ssh/authorized_keys
# curl -fsSL https://bun.sh/install | bash
# chmod a+rx ~ ~/.bun ~/.bun/bin ~/.bun/bin/bun ~/.bun/bin/bunx
# git init islego-web --initial-branch=main --shared=600
# cd islego-web
# git config receive.denycurrentbranch ignore
# on local -> git remote add deploy islego@123.45.67.89:islego-web
# on local -> git push deploy
# git checkout main
# ln -fs ../../post-receive.sh .git/hooks/post-receive
# --> as root
# cd ~islego/islego-web
# mkdir public/uploads
# chmod 775 public/uploads
# mkdir sqlite
# chmod 770 sqlite
# touch sqlite/sqlite.db
# chmod 660 sqlite/sqlite.db
# chown -R islego-web:islego sqlite
# cp islego-web.service /etc/systemd/system/islego-web.service
# systemctl daemon-reload
# systemctl enable islego-web
# sudoedit /etc/sudoers.d/islego
# islego ALL=NOPASSWD: /usr/bin/systemctl ^(start|status|stop( --force)?|restart) islego-web$
# ssh islego@123.45.67.89
# cd .git
# hooks/post-receive <<< "- - refs/heads/main"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment