2.6 KiB
Deployment Instructions for AWS EC2
This guide will help you deploy the WonderSheets application to your EC2 instance using Docker.
Prerequisites
- AWS EC2 Instance: A running instance (e.g., Amazon Linux 2 or Ubuntu).
- Security Group Rules: Ensure your EC2 Security Group allows:
- Inbound HTTP (Port 80): For the web interface.
- Inbound SSH (Port 22): For you to connect.
- API Key: Your Google Gemini API Key.
Step 1: Connect to your EC2 Instance
Open your terminal and SSH into your server:
ssh -i /path/to/your-key.pem user@your-ec2-public-ip
Step 2: Install Docker and Docker Compose (if not installed)
For Amazon Linux 2023 / Amazon Linux 2:
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
# Logout and log back in to apply group changes
exit
# ssh again...
Install Docker Compose:
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
(If you are using Ubuntu, use sudo apt update && sudo apt install docker.io docker-compose -y)
Step 3: Get the Code
You can either clone the repository or upload your files.
Option A: Git Clone (Recommended) If your code is on Gitea/GitHub:
git clone <your-repo-url>
cd wondersheets
Option B: Upload Files If you want to copy local files:
scp -i /path/to/key.pem -r . user@your-ec2-ip:~/wondersheets
Step 4: Configure Environment
Create a .env file in the project directory:
nano .env
Paste your API key:
GEMINI_API_KEY=your_actual_api_key_here
Save and exit (Ctrl+O, Enter, Ctrl+X).
Step 5: Start the Application
Run the application in the background:
docker-compose up -d --build
Step 6: Verify
From your browser
Open your browser and visit your EC2 Public IP:
http://your-ec2-public-ip/
The app should be running!
From the server terminal (SSH)
You can check if the server is running correctly directly on the instance:
-
Check running containers:
docker-compose psYou should see
wondersheets-backend-1andwondersheets-frontend-1with statusUp. -
Check local connection:
curl -I http://localhostYou should see
HTTP/1.1 200 OK. -
View Logs:
docker-compose logs -f
Troubleshooting
- Check logs:
docker-compose logs -f - Restart:
docker-compose restart - Stop:
docker-compose down