What is SnakeBytes?
I have a long history of code tutoring (for fun and work) with peers and younger students. I started SnakeBytes to teach more kids coding, as I find it fun and also a valuable skill worth sharing.
- React (via Next.js)
- Next.js (App Router)
- TypeScript
- Tailwind CSS (via PostCSS)
- urql (GraphQL client)
- NextAuth.js (authentication)
- Stripe.js (payments)
- Lucide React (icons)
- Node.js
- TypeScript
- Apollo Server (GraphQL server)
- type-graphql (GraphQL schema and resolvers)
- TypeORM (ORM for database)
- PostgreSQL (database)
- jsonwebtoken (JWT handling)
- Express.js (API server)
- Stripe (payments)
- dotenv (environment variable management)
- Caddy (web server/reverse proxy)
- Docker (Dockerfiles for frontend and backend)
- Cloudflare (DNS/proxy)
- AWS EC2 (deployment)
- TurboRepo (monorepo management)
- Yarn/NPM workspaces
- Redis (Caching content & not soley relying on Supabase)
This guide walks you through how to deploy your local SnakeBytes project to your AWS EC2 instance using rsync, Docker Compose, and Caddy.
Make sure you have the following installed and configured:
- AWS EC2 instance (Ubuntu-based)
- Docker & Docker Compose installed on EC2
- Caddy installed and set up as a reverse proxy (optional HTTPS)
- SSH key added to
~/.sshon your local machine - Your EC2 instance’s public IP or hostname
- CHECK THIS PLEASE: Local project is fully working (Are all files there? Certs?)
ssh -i ~/.ssh/calgary-bryan-arch.pem ubuntu@ec2-35-183-184-18.ca-central-1.compute.amazonaws.comFrom your local project root (snakebyte/), run:
From your local project root (snakebyte/), run:
rsync -avz \
--exclude 'deploy-snakebytes.sh' \
--exclude 'node_modules' \
--exclude '.next' \
--exclude '.git' \
--exclude '.env' \
--exclude '.env.local' \
--exclude '*/.env' \
--exclude '*/.env.local' \
--exclude 'build' \
--exclude 'dist' \
--exclude '.turbo' \
--exclude '.DS_Store' \
--exclude '*.log' \
--exclude '.vercel' \
--exclude 'coverage' \
--exclude '*.tsbuildinfo' \
--exclude 'packages/shared' \
-e "ssh -i ~/.ssh/calgary-bryan-arch.pem" \
. ubuntu@ec2-35-183-184-18.ca-central-1.compute.amazonaws.com:~/snakebyteInside the ~/snakebyte (cd ~/snakebyte) directory in the EC2 instance, run:
sudo docker-compose down
sudo docker-compose up -d --buildThen start/restart Caddy for reverse proxy/SSL to access from the web.
If first time running Caddy on instance: sudo systemctl start caddy
If not: sudo systemctl restart caddy
Create a script (deploy-snakebytes.sh) in snakebyte @ local:
#!/bin/bash
if [ ! -f "docker-compose.yml" ]; then
echo "Please run this script from your snakebyte project root."
exit 1
fi
rsync -avz \
--exclude 'deploy-snakebytes.sh' \
--exclude 'node_modules' \
--exclude '.next' \
--exclude '.git' \
--exclude '.env' \
--exclude '.env.local' \
--exclude '*/.env' \
--exclude '*/.env.local' \
--exclude 'build' \
--exclude 'dist' \
--exclude '.turbo' \
--exclude '.DS_Store' \
--exclude '*.log' \
--exclude '.vercel' \
--exclude 'coverage' \
--exclude '*.tsbuildinfo' \
--exclude 'packages/shared' \
-e "ssh -i ~/.ssh/calgary-bryan-arch.pem" \
. ubuntu@ec2-35-183-184-18.ca-central-1.compute.amazonaws.com:~/snakebyte
ssh -i ~/.ssh/calgary-bryan-arch.pem ubuntu@ec2-35-183-184-18.ca-central-1.compute.amazonaws.com << 'EOF'
cd ~/snakebyte
sudo docker compose down
sudo docker compose up -d --build
sudo systemctl restart caddy
EOFMake it an executable with chmod +x deploy-snakebytes.sh and then run it with ./deploy-snakebytes.sh.