Last active
December 6, 2025 06:10
-
-
Save joshnuss/3c4d3fd1e407ddfb97646657e4de72a0 to your computer and use it in GitHub Desktop.
SvelteKit & Postgres on AWS LightSail
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
| export ASDF_VERSION=0.18.0 | |
| export NODE_VERSION=25.2.1 | |
| # make sure we're up to date | |
| sudo apt update --yes | |
| # add dependencies for asdf and nodejs | |
| sudo apt install --yes git bash rsync libatomic1 | |
| # add asdf | |
| wget https://github.com/asdf-vm/asdf/releases/download/v${ASDF_VERSION}/asdf-v${ASDF_VERSION}-linux-386.tar.gz | |
| tar -xvf asdf-v${ASDF_VERSION}-linux-386.tar.gz | |
| mkdir bin | |
| mv asdf bin/ | |
| # add asdf to path | |
| echo "export PATH=\"\$PATH:~/bin\"" > ~/.bash_profile | |
| echo "export PATH=\"\${ASDF_DATA_DIR:-\$HOME/.asdf}/shims:\$PATH\"" >> ~/.bash_profile | |
| source ~/.bash_profile | |
| # add node.js | |
| asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git | |
| asdf install nodejs $NODE_VERSION | |
| asdf set nodejs $NODE_VERSION | |
| asdf reshim | |
| # install pnpm | |
| curl -fsSL https://get.pnpm.io/install.sh | sh - | |
| source ~/.bashrc | |
| # install pm2 | |
| pnpm install --global pm2 | |
| # route tcp port 80 to port 3000 | |
| sudo iptables -t nat -A PREROUTING -i ens5 -p tcp --dport 80 -j REDIRECT --to-port 3000 | |
| # install postgres | |
| sudo apt install --yes postgresql postgresql-client | |
| # setup postgres | |
| cat > setup.sql <<'EOF' | |
| CREATE DATABASE example; | |
| ALTER USER postgres WITH PASSWORD 'postgres'; | |
| GRANT ALL PRIVILEGES ON DATABASE example TO postgres; | |
| EOF | |
| sudo -u postgres psql -f setup.sql | |
| mkdir app | |
| # to build locally: | |
| # pnpm build | |
| # | |
| # to sync from local: | |
| # rsync -chavzP --stats . [email protected]:~/app | |
| cd app | |
| pnpm pm2 start build/index.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment