This detailed guide walks you through deploying CredibilityCheckerRAG on an AWS EC2 t2.micro instance (completely Free Tier eligible).
- An active AWS Account (Sign up here).
- Your GitHub/GitLab Credentials (Username and Personal Access Token or Password) ready for cloning.
- Your Mistral/OpenAI API Keys ready.
- Log in to the AWS Management Console.
- In the search bar at the top, type
EC2and select EC2 from the results. - On the EC2 Dashboard, click the orange Launch instance button.
- Name and tags:
- In the "Name" field, type:
CredibilityChecker-Server
- In the "Name" field, type:
- Application and OS Images (Amazon Machine Image):
- Select Ubuntu.
- Ensure "Free tier eligible" is listed under the version (e.g., Ubuntu Server 22.04 LTS). This is the safest default.
- Instance type:
- Select t2.micro (1 vCPU, 1 GiB Memory). This is Free Tier eligible.
- Key pair (login):
- Click Create new key pair.
- Key pair name:
credibility-key - Key pair type: RSA
- Private key file format:
.pem(for Mac/Linux/Powershell) or.ppk(for older PuTTY)..pemis recommended. - Click Create key pair. The file will download automatically. Keep this safe; you cannot download it again.
- Network settings:
- Firewall (security groups): Select "Create security group".
- Check Allow SSH traffic from. Ideally set to
My IPfor security, orAnywhere (0.0.0.0/0)for convenience. - Check Allow HTTP traffic from the internet.
- Check Allow HTTPS traffic from the internet.
- Crucial Step: We need to open port 5000 (Flask default). We will do this after launch to be precise.
- Configure storage:
- Default is 8 GiB gp2/gp3. This is fine. You can increase to 20 GiB (Free Tier limit is 30GB total) if you want more space.
- Click the orange Launch instance button on the right.
- Click View all instances to see your new server initializing.
By default, standard web ports (80/443) are open, but Flask runs on 5000.
- In the EC2 Dashboard -> Instances, check the box next to your
CredibilityChecker-Server. - Click the Security tab in the bottom pane.
- Click the link under Security groups (it looks like
sg-01234abcd...). - In the new window identifying the security group, click the Inbound rules tab.
- Click Edit inbound rules.
- Click Add rule (bottom left).
- Type: Select
Custom TCP. - Port range: Type
5000. - Source: Select
Anywhere-IPv4(0.0.0.0/0). - Description (optional): "Flask App Port".
- Type: Select
- Click Save rules.
The easiest way is using the browser (no keys needed).
- Go back to Instances.
- Select your instance
CredibilityChecker-Server. - Click the Connect button (top right).
- Select the EC2 Instance Connect tab.
- Click Connect.
- A new browser tab will open with a black terminal screen. You are now "inside" your server!
Run these commands in the black terminal window.
Replace <YOUR_REPO_URL> with your actual repository URL.
Note: If your repo is private, it will ask for Username and Password. For Password, you essentially need a GitHub Personal Access Token.
# Example: git clone https://github.com/yourusername/CredibilityCheckerRAG.git
git clone <YOUR_REPO_URL>Once cloned, move into the directory:
cd CredibilityCheckerRAG/v3
# OR whatever the folder name is. Type 'ls' to see the folder name.
# e.g., cd CredibilityCheckerRAGI have included a helper script to do all the heavy lifting (installing Python, creating a swap file to prevent crashing, setting up virtual environment).
# Make the script executable
chmod +x deploy_ec2.sh
# Run it
./deploy_ec2.shWait for this to finish. It may take 2-5 minutes.
You need to create the .env file on the server.
- Open the text editor
nano:nano .env
- Now, paste your API keys. (Right-click in the terminal window usually pastes).
MISTRAL_API_KEY=your_actual_api_key_here # Add any other keys from your local .env
- To Save and Exit nano:
- Press
Ctrl + X(to exit). - Press
Y(to say Yes to saving). - Press
Enter(to confirm the filename).
- Press
Run the start script created by the deploy script:
./start_app.shYou should see output saying [INFO] Starting gunicorn... and Listening at: http://0.0.0.0:5000.
- Go back to the AWS Console -> Instances.
- Find your instance and look for Public IPv4 address (e.g.,
54.123.45.67). - Open a new browser tab on your computer.
- Go to:
http://<YOUR_PUBLIC_IP>:5000- Example:
http://54.123.45.67:5000
- Example:
Success! You should see your application running.
- "This site can't be reached":
- Did you mistakenly use
https://? Make sure it ishttp://(unless you set up SSL). - Did you do Part 2 (Security Groups) correctly? Verify Port 5000 is open to
0.0.0.0/0.
- Did you mistakenly use
- "MemoryError" or "Killed" during installation:
- The
t2.microhas only 1GB RAM. Ensure./deploy_ec2.shran successfully—it creates a "swap file" that acts as extra RAM.
- The
- Deployment script permission denied:
- Did you run
chmod +x deploy_ec2.sh?
- Did you run