Skip to content

Commit

Permalink
updated and added ai based chatbot with dockerized env
Browse files Browse the repository at this point in the history
  • Loading branch information
MIKEINTOSHSYSTEMS committed Jul 13, 2024
1 parent 47a16e1 commit 2d1f6ba
Show file tree
Hide file tree
Showing 11 changed files with 1,198 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
*.xls
*.xlsx
*.txt
!mysql-init/init.sql
!mysql-init/init.sql
/ai/venv
44 changes: 40 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
################################################################################
# Base image
# Base image for PHP application
################################################################################

# Use an official PHP runtime as a parent image
#FROM php:7.4-apache

# Use an official PHP-FPM runtime as a parent image
FROM php:7.4-fpm
FROM php:7.4-fpm AS php_app

# Set the image name and tag as labels
LABEL maintainer="MIKEINTOSH SYSTEMS <mikeintoshsys@gmail.com>"
Expand Down Expand Up @@ -47,6 +47,9 @@ COPY pwabuilder-sw.js /var/www/html/
COPY manifest.json /var/www/html/
COPY 404.php /var/www/html/

# Copy AI chat files to the container
COPY ai/ /var/www/html/ai/

# Copy custom nginx configurations
COPY config/nginx.conf /etc/nginx/conf.d/default.conf

Expand All @@ -64,6 +67,39 @@ RUN apt-get update && \
# Expose the port PHP-FPM listens on
EXPOSE 9000

# Start Apache when the container runs
#CMD ["apache2-foreground"]
# Start PHP-FPM when the container runs
CMD ["php-fpm"]

################################################################################
# Base image for AI Chatbot Service
################################################################################

# Use an official Python runtime as a parent image
FROM python:3.9-slim AS ai_chatbot

WORKDIR /ai/chat

RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
&& rm -rf /var/lib/apt/lists/*

# Copy requirements.txt first to leverage Docker cache
COPY ai/chat/requirements.txt /ai/chat/

# Install dependencies
RUN pip install -r requirements.txt

# Copy the rest of the AI application
COPY ai/chat/ /ai/chat/

# Expose the port Streamlit listens on
EXPOSE 8502

# Healthcheck for the Streamlit service
HEALTHCHECK CMD curl --fail http://localhost:8502/_stcore/health

# Start Streamlit when the container runs
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8502", "--server.address=0.0.0.0"]
6 changes: 6 additions & 0 deletions ai/chat/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_USER=dere_admin
MYSQL_PASSWORD=dere_admin
MYSQL_DATABASE=dere_dev
GROQ_API_KEY=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
27 changes: 27 additions & 0 deletions ai/chat/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ./chat/Dockerfile

FROM python:3.9-slim

WORKDIR /chat

RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
&& rm -rf /var/lib/apt/lists/*

# Copy requirements.txt first to leverage Docker cache
COPY requirements.txt .

# Install dependencies
RUN pip install -r requirements.txt

# Copy the rest of the application
COPY . .

EXPOSE 8502

HEALTHCHECK CMD curl --fail http://localhost:8502/_stcore/health

ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8502", "--server.address=0.0.0.0"]
Loading

0 comments on commit 2d1f6ba

Please sign in to comment.