fabriziosalmi / UglyFeed

Retrieve, aggregate, filter, evaluate, rewrite and serve RSS feeds using Large Language Models for fun, research and learning purposes.
GNU Affero General Public License v3.0
118 stars 3 forks source link

dockerize the Ugly #6

Closed fabriziosalmi closed 3 months ago

fabriziosalmi commented 4 months ago

barely tested, ongoing testing

Leopere commented 4 months ago

I got this if you can help me use the thing.

fabriziosalmi commented 4 months ago

I'm stalling on this a bit since I want before to improve the app :) thank you I'll ping once needed OFC 👯

Leopere commented 4 months ago

this is something that I directly wish to have currently so anything that i can do is fine.

fabriziosalmi commented 3 months ago

Step 1: Create a Dockerfile

Create a file named Dockerfile in the same directory as your Streamlit app (app.py). This file will define the image with all the necessary dependencies.

# Use the official Python image as a base
FROM python:3.10-slim

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file to the working directory
COPY requirements.txt .

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the current directory contents into the container at /app
COPY . .

# Expose the port Streamlit will run on
EXPOSE 8501

# Command to run the Streamlit app
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]

Step 2: Create a requirements.txt File

This file lists all the Python dependencies required by your app. Create a requirements.txt file in the same directory and include the following dependencies:

streamlit
pyyaml

Add any other dependencies your app might need.

Step 3: Build the Docker Image

Open a terminal in the directory containing your Dockerfile and requirements.txt, and run the following command to build your Docker image. Replace my-streamlit-app with your preferred image name.

docker build -t my-streamlit-app .

Step 4: Run the Docker Container

Once the image is built, you can run the container with the following command:

docker run -p 8501:8501 my-streamlit-app

This maps port 8501 of the Docker container to port 8501 on your local machine, allowing you to access the Streamlit app in your browser at http://localhost:8501.

Complete Example

If you combine everything, your directory structure should look like this:

/your-app-directory
|-- app.py
|-- Dockerfile
|-- requirements.txt
|-- input/
|-- output/
|-- rewritten/

And the contents of each file would be as follows:

Additional Considerations

This setup provides a portable and consistent environment for running your Streamlit app, making it easy to deploy and share with others.

fabriziosalmi commented 3 months ago

https://github.com/fabriziosalmi/UglyFeed/commit/8648f7e707c1ac6b5e7eddcfd6b24153dcd0903a

Leopere commented 3 months ago

I had just seen your post on Reddit I still really would love to use this simply to apply certain prompts to certain feeds. or maybe do multiple rounds of that with different agents kinda deal. Break down jobs etc idk this is all a lot.

Leopere commented 3 months ago

Why is this image almost 6gb?!?!

fabriziosalmi commented 3 months ago

Why is this image almost 6gb?!?!

it get transformers, PyTorch and dictionaries to make it working in both Italian and English.. also it supports all scripts to evaluate metrics of generated content and comparison between generated and source content. in the future I'll make it smaller giving the option to get it 2 ways, minimal or full :) it's not a close future anyway :)

if u want to avoid large download and docker just go pure python and web UI via

streamlit run gui.py --server.port=8501 --server.address=192.168.0.2 (used example values for custom port and listen address)

fabriziosalmi commented 3 months ago

make docker image smaller tracked here: https://github.com/fabriziosalmi/UglyFeed/issues/19