APP in ElasticBeanstalk

0

I have an application built with Python and Streamlit as the front-end library. I deployed it on Elastic Beanstalk, but when loading through the console or directly, the package does not recognize the Procfile or my configurations. However, the most critical issue is the Procfile since it does not deploy on the port that Streamlit runs on, nor does it execute it. Instead, it loads the default one. I have tried redoing the project, loading it locally, and I have the correct structure, but it still doesn't work.

  • please accept the answer if it was useful

asked 16 days ago77 views
2 Answers
0

Deploying a Streamlit application on AWS Elastic Beanstalk (EB) can be tricky, especially with configuration files like Procfile not being recognized correctly. Here are some steps and considerations to ensure a successful deployment:

1. Verify Procfile Configuration: Ensure that your Procfile is correctly defined and located in the root directory of your project. For a Streamlit application, the Procfile should typically look something like this:

web: streamlit run app.py --server.port=$PORT

Replace app.py with the name of your main Streamlit application file.

2. Check Directory Structure: Your project directory should have the following structure:

├── .ebextensions/
│   └── (your config files, if any)
├── Procfile
├── requirements.txt
├── app.py
└── (other files)

3. Environment Configuration: Make sure that you have the necessary environment configurations. This can be done using the .ebextensions directory to set environment variables, install packages, or perform other setup tasks.

Create a file like .ebextensions/python.config with the following content:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: app:application

container_commands:
  01_migrate:
    command: "streamlit run app.py --server.port=$PORT"

4. Port Configuration: AWS Elastic Beanstalk uses port 5000 by default. Streamlit, by default, runs on port 8501. Make sure to set Streamlit to run on the port that EB expects. You can do this by setting the --server.port parameter to $PORT in the Procfile.

5. Logging and Debugging: Check the logs on Elastic Beanstalk to get more details on what might be going wrong. You can do this via the AWS Management Console or the EB CLI with the command:

eb logs

6. Requirements.txt: Ensure that all the required packages are listed in your requirements.txt file, including streamlit.

7. Re-deploying the Application: After making these changes, try re-deploying your application. If you are using the EB CLI, you can run:

eb deploy

8. Example Configuration: Here is a sample project setup for reference:

Procfile:

web: streamlit run app.py --server.port=$PORT

.ebextensions/python.config:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: app:application

container_commands:
  01_migrate:
    command: "streamlit run app.py --server.port=$PORT"

requirements.txt:

streamlit

app.py:

import streamlit as st

st.title("Hello, Elastic Beanstalk!")
st.write("This is a Streamlit app deployed on AWS Elastic Beanstalk.")

By following these steps and ensuring your configuration files are correctly set up, you should be able to deploy your Streamlit application on Elastic Beanstalk successfully. If you encounter specific errors, checking the logs and providing those details can help diagnose further.

profile picture
EXPERT
answered 16 days ago
profile picture
EXPERT
reviewed 16 days ago
0

I've tried everything you mentioned, I have checked my files and structure over and over again, I have directly accessed the instance to review the logs, and it's always the same, it does not detect my Procfile, therefore, it creates a default one. I don't know where the error is.

Structure

Logs

 CommandService Response: {"status":"SUCCESS","api_version":"1.0","results":[{"status":"SUCCESS","msg":"Engine execution has succeeded.","returncode":0,"events":[{"msg":"Instance deployment successfully generated a 'Procfile'.","timestamp":1715792267407,"severity":"INFO"},{"msg":"Instance deployment completed successfully.","timestamp":1715792274807,"severity":"INFO"}]}]}

Procfile

web: streamlit run app.py --server.port=5000
answered 16 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions