Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker compose as an alternative setup option #85

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ pip3 install -r requirements.txt #installing the env
cd solidportal/panel
npm i && npm start
```
- ## With docker compose
Run `docker compose up`.



Expand Down
35 changes: 35 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
services:
redis:
image: redis:alpine
ports:
- "6379:6379"
api:
build:
context: .
dockerfile: dockerfiles/Dockerfile.api
depends_on:
- redis
ports:
- "8000:8000"
environment:
- BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be CELERY_RESULT_BACKEND=redis://redis:6379/1, so that we use database 0 for the broker and database 1 for the results backend.

worker:
build:
context: .
dockerfile: dockerfiles/Dockerfile.worker
depends_on:
- redis
environment:
- BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

webui:
build:
context: .
dockerfile: dockerfiles/Dockerfile.webui
depends_on:
- api
ports:
- "3000:3000"


13 changes: 13 additions & 0 deletions dockerfiles/Dockerfile.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use an official Python runtime as the parent image
FROM python:3.11.5-bullseye

# Set the working directory in the container to /app
WORKDIR /app

# Copy the current directory (where the Dockerfile is) into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

CMD export PYTHONPATH=$PYTHONPATH:$(git rev-parse --show-toplevel)/ && uvicorn solidgpt.src.api.api:app --proxy-headers --host 0.0.0.0 --port 8000
17 changes: 17 additions & 0 deletions dockerfiles/Dockerfile.webui
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Use an official Node.js runtime as the parent image
FROM node:latest

# Set the working directory in the container to /app
WORKDIR /app
COPY . /app

# Change directory to solidportal/panel
WORKDIR /app/solidportal/panel

# Copy the current directory (where the Dockerfile is) into the container at /app

# Install any needed packages specified in package.json
RUN npm install

# Start the application
CMD ["npm", "start"]
13 changes: 13 additions & 0 deletions dockerfiles/Dockerfile.worker
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use an official Python runtime as the parent image
FROM python:3.11.5-bullseye

# Set the working directory in the container to /app
WORKDIR /app

# Copy the current directory (where the Dockerfile is) into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

CMD export PYTHONPATH=$PYTHONPATH:$(git rev-parse --show-toplevel)/ && celery -A solidgpt.src.api.celery_tasks worker --loglevel=info
6 changes: 4 additions & 2 deletions solidgpt/src/api/celery_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# celery -A solidgpt.src.api.celery_tasks worker --loglevel=info -P eventlet
# celery_config.py

BROKER_URL = 'redis://localhost:6379/0' # Using Redis as the broker
CELERY_RESULT_BACKEND = 'redis://localhost:6379/1'
import os

BROKER_URL = os.getenv('BROKER_URL', 'redis://localhost:6379/0') # Using Redis as the broker
CELERY_RESULT_BACKEND = os.getenv('CELERY_RESULT_BACKEND', 'redis://localhost:6379/1')
4 changes: 2 additions & 2 deletions solidgpt/src/api/celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from solidgpt.src.manager.initializer import *

app = Celery('celery_tasks',
BROKER_URL='redis://localhost:6379/0', # Using Redis as the broker
CELERY_RESULT_BACKEND='redis://localhost:6379/1'
BROKER_URL=os.getenv('BROKER_URL', 'redis://localhost:6379/0'), # Using Redis as the broker
CELERY_RESULT_BACKEND=os.getenv('CELERY_RESULT_BACKEND', 'redis://localhost:6379/1')
)
app.autodiscover_tasks(['solidgpt.src.api'])
Initializer()
Expand Down