From 233563849c75d14a83366343291731bd7e93049b Mon Sep 17 00:00:00 2001 From: markjacksonfishing Date: Wed, 11 Dec 2024 09:52:58 -0800 Subject: [PATCH] Fixes Containerized the application for use in Kubernetes #27 Signed-off-by: markjacksonfishing --- Dockerfile | 34 ++++++++++++++++++ README.md | 70 ++++++++++++++++++++++++++++++++++++ app.py | 2 -- src/data_acquisition.py | 2 -- src/data_processing.py | 2 -- src/recommendation_engine.py | 2 -- src/solunar_calculations.py | 2 -- 7 files changed, 104 insertions(+), 10 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..57d4af3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# Use an official Python image as the base +FROM python:3.9-slim + +# Set environment variables to ensure Python behaves well in Docker +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 + +# Set the working directory in the container +WORKDIR /app + +# Install system dependencies for Python and the app (e.g., build tools, if needed) +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + libpq-dev \ + && rm -rf /var/lib/apt/lists/* + +# Copy only the requirements first for efficient Docker caching +COPY requirements.txt /app/requirements.txt + +# Install Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code +COPY . /app + +# Expose the application's port (adjust if needed) +EXPOSE 5000 + +# Health check to ensure the app is running +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl --fail http://localhost:5000/health || exit 1 + +# Default command to run the application +CMD ["python", "app.py"] diff --git a/README.md b/README.md index 5048a32..6b924aa 100644 --- a/README.md +++ b/README.md @@ -238,6 +238,76 @@ This module uses solunar theory to recommend the best times for bass fishing. --- +Here’s an updated version of the `README.md` with Docker-specific instructions included: + +--- + +# Solunar Bass Forecasting Tool 🎣 + +[![UptimeRobot status](https://img.shields.io/badge/status-up-green.svg)](https://stats.uptimerobot.com/AQLeOzd84C) + +![SolunarBass](assets/solunarbass.png) + +Welcome to **Solunar Bass**, an open-source project by **Bassfinity** that helps bass fishermen maximize their fishing success using solunar theory, data acquisition, and personalized recommendations. This repository powers a web app that predicts optimal bass fishing times based on solunar data, weather conditions, and location. You can view the website [here](https://solunarbass-h9jxdwh8usuzhpix2yessm.streamlit.app) + +--- + +## New: Run with Docker 🐋 + +You can now run the Solunar Bass Forecasting Tool using Docker. Follow the steps below to build and run the Docker container. + +### Prerequisites + +- Install [Docker](https://docs.docker.com/get-docker/) on your system. + +--- + +### Run the Application Using Docker + +1. **Pull the Prebuilt Image** + The Docker image is available on Docker Hub. Pull it using: + ```bash + docker pull anuclei/solunarbass:latest + ``` + +2. **Run the Container** + Start the container and map the appropriate ports: + ```bash + docker run -p 8501:8501 anuclei/solunarbass:latest + ``` + +3. **Access the Application** + Open your browser and navigate to: + ``` + http://localhost:8501 + ``` + +--- + +### Build the Docker Image Locally (Optional) + +If you want to build the image yourself: + +1. **Clone the Repository** + ```bash + git clone https://github.com/bassfinity/solunarbass.git + cd solunarbass + ``` + +2. **Build the Image** + Use the following command to build the Docker image: + ```bash + docker build -t anuclei/solunarbass:latest . + ``` + +3. **Run the Container** + ```bash + docker run -p 8501:8501 anuclei/solunarbass:latest + ``` +If you just perfer to pull the image from docker hub, you can use the following[image](https://hub.docker.com/repository/docker/anuclei/solunarbass/general) + +--- + ## Contributing Contributions are welcome! If you want to contribute to the project, follow these steps: diff --git a/app.py b/app.py index 9360741..231f6e7 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,3 @@ -# app.py - import streamlit as st from datetime import date, datetime from streamlit_js_eval import streamlit_js_eval # For geolocation diff --git a/src/data_acquisition.py b/src/data_acquisition.py index 1f84f70..38fb5dc 100644 --- a/src/data_acquisition.py +++ b/src/data_acquisition.py @@ -1,5 +1,3 @@ -# src/data_acquisition.py - import os import requests import streamlit as st diff --git a/src/data_processing.py b/src/data_processing.py index 62e8595..a9afe61 100644 --- a/src/data_processing.py +++ b/src/data_processing.py @@ -1,5 +1,3 @@ -# src/data_processing.py - from datetime import datetime def process_solunar_data(data, date_str): diff --git a/src/recommendation_engine.py b/src/recommendation_engine.py index 4bd5ded..a194178 100644 --- a/src/recommendation_engine.py +++ b/src/recommendation_engine.py @@ -1,5 +1,3 @@ -# src/recommendation_engine.py - def generate_recommendations(major_times, minor_times): recommendations = [] diff --git a/src/solunar_calculations.py b/src/solunar_calculations.py index b2e4b59..ea15288 100644 --- a/src/solunar_calculations.py +++ b/src/solunar_calculations.py @@ -1,5 +1,3 @@ -# src/solunar_calculations.py - from datetime import timedelta def calculate_major_minor_times(solunar_data):