Spaces:
Sleeping
Sleeping
Update README.md
Browse files9 unmodified lines1011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241259 unmodified lines---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference# Deploying a Streamlit App on AWS EC2This guide will walk you through the steps to deploy your Streamlit application on an AWS EC2 instance.## Prerequisites1. A Streamlit app designed and tested locally with the following structure:- `requirements.txt`- `app.py`2. An AWS account.## Steps to Deploy### 1. Launch an EC2 Instance1. Log in to your AWS account.2. Navigate to the EC2 Dashboard.3. Click on "Launch Instance."4. Name your instance `streamlit-test`.5. Choose an Amazon Machine Image (AMI). You can use the default Amazon Linux 2 AMI.6. Select an instance type (e.g., t2.micro for free tier eligibility).7. Configure the instance details as required.8. Add storage if necessary.9. Add tags if desired.10. Configure the security group:- Click on "Add Rule."- Set the "Type" to "Custom TCP."- Set the "Port Range" to `8501` (Streamlit's default port).- Set "Source" to `Anywhere` to allow access from any IP (or restrict to your IP for security).- Click "Save rules."### 2. Create and Download the Key Pair1. When prompted, create a new key pair.2. Name the key pair `streamlit-test-key`.3. Download the `.pem` file and save it in a directory of your choice.### 3. Connect to the EC2 Instance1. In the EC2 Dashboard, go to "Instances."2. Click on the `Instance ID` of your newly created instance.3. Click on "Connect."4. Follow the instructions to connect using SSH. The command should look like this:```shssh -i "streamlit-test-key.pem" ec2-user@<your-ec2-public-dns>```Replace `<your-ec2-public-dns>` with your instance's public DNS.### 4. Copy Local Files to the EC2 Instance1. Open another terminal window.2. Navigate to the directory containing your `.pem` key file and Streamlit app.3. Use `scp` to copy your local files to the EC2 instance:```shscp -i "streamlit-test-key.pem" -r ./meta-llama3-full-stack/* ec2-user@<your-ec2-public-dns>:/home/ec2-user/```Replace `<your-ec2-public-dns>` with your instance's public DNS.### 5. Set Up the EC2 Environment1. Once connected to the EC2 instance via SSH, create a virtual environment:```shpython3 -m venv venvsource venv/bin/activate```2. Navigate to the project directory and install the required packages:```shcd /home/ec2-user/meta-llama3-full-stackpip install -r requirements.txt```### 6. Run the Streamlit App1. For a temporary run, simply execute:```shstreamlit run app.py```2. For a persistent run, use `nohup`:```shnohup streamlit run app.py &```### 7. Access the Streamlit App1. Open your web browser and navigate to:```shhttp://<your-ec2-public-dns>:8501```Replace `<your-ec2-public-dns>` with your instance's public DNS.### Code ReferenceThe code for the Streamlit app can be found here: [Meta Llama 3 Full Stack](https://huggingface.co/spaces/eagle0504/meta-llama3-full-stack)### Notes- Ensure that your security group rules are correctly configured to allow inbound traffic on port 8501.- Keep your `.pem` file secure and do not share it.Following these steps will help you successfully deploy your Streamlit app on an AWS EC2 instance.9 unmodified lines1011129 unmodified lines---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
README.md-113