new dockerfiles for dev and prod containers, updated / added new compose files for standalone, dev, and aio

This commit is contained in:
kappa118 2025-03-01 18:37:26 -05:00
parent cc42dfb887
commit 573655d269
6 changed files with 158 additions and 54 deletions

View file

@ -1,37 +1,53 @@
FROM python:3.10-slim
FROM alpine
# Install required packages including ffmpeg, streamlink, and vlc
RUN apt-get update && apt-get install -y \
ffmpeg \
streamlink \
vlc \
libpq-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*
ENV PATH="/dispatcharrpy/bin:$PATH" \
VIRTUAL_ENV=/dispatcharrpy \
DJANGO_SETTINGS_MODULE=dispatcharr.settings \
PYTHONUNBUFFERED=1
RUN apk add \
python3 \
python3-dev \
gcc \
musl-dev \
linux-headers \
py3-pip \
ffmpeg \
streamlink \
vlc \
libpq-dev \
gcc \
py3-virtualenv \
uwsgi \
uwsgi-python \
nodejs \
npm \
git \
redis
RUN \
virtualenv /dispatcharrpy && \
git clone https://github.com/Dispatcharr/Dispatcharr /app && \
cd /app && \
/dispatcharrpy/bin/pip install --no-cache-dir -r requirements.txt && \
cd /app/frontend && \
npm install && \
npm run build && \
find . -maxdepth 1 ! -name '.' ! -name 'build' -exec rm -rf '{}' \; && \
cd /app && \
python manage.py collectstatic --noinput || true
# Cleanup
RUN \
apk del \
nodejs \
npm \
git \
gcc \
musl-dev \
python3-dev \
linux-headers
# Set the working directory
WORKDIR /app
ENV API_PORT=5656
# Install Python dependencies
COPY requirements.txt /app/
RUN pip install --no-cache-dir -r requirements.txt
# Copy application files
COPY . /app/
# Set environment variables
ENV DJANGO_SETTINGS_MODULE=dispatcharr.settings
ENV PYTHONUNBUFFERED=1
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
# Run Django commands
RUN python manage.py collectstatic --noinput || true
RUN python manage.py migrate --noinput || true
# Expose port 9191 (this is the port the app will listen on inside the container)
EXPOSE 9191
# Command to run the application binding to host and port
CMD ["gunicorn", "--workers=4", "--worker-class=gevent", "--timeout=300", "--bind", "0.0.0.0:5656", "dispatcharr.wsgi:application"]
CMD ["/app/docker/entrypoint.aio.sh"]

52
docker/Dockerfile.dev Normal file
View file

@ -0,0 +1,52 @@
FROM alpine
ENV PATH="/dispatcharrpy/bin:$PATH" \
VIRTUAL_ENV=/dispatcharrpy \
DJANGO_SETTINGS_MODULE=dispatcharr.settings \
PYTHONUNBUFFERED=1
RUN apk add \
python3 \
python3-dev \
gcc \
musl-dev \
linux-headers \
py3-pip \
ffmpeg \
streamlink \
vlc \
libpq-dev \
gcc \
py3-virtualenv \
uwsgi \
uwsgi-python \
nodejs \
npm \
git \
redis
COPY ./ /app/
RUN \
mkdir /data && \
virtualenv /dispatcharrpy && \
cd /app && \
/dispatcharrpy/bin/pip install --no-cache-dir -r requirements.txt && \
cd /app/frontend && \
npm install && \
cd /app && \
python manage.py collectstatic --noinput || true
# Cleanup
RUN \
apk del \
git \
gcc \
musl-dev \
python3-dev \
linux-headers
WORKDIR /app
CMD ["/usr/sbin/uwsgi", "--ini", "uwsgi.ini"]
# CMD ["gunicorn", "--workers=4", "--worker-class=gevent", "--timeout=300", "--bind", "0.0.0.0:5656", "dispatcharr.wsgi:application"]

View file

@ -0,0 +1,16 @@
services:
web:
# build:
# context: ..
# dockerfile: docker/Dockerfile.alpine
image: dispatcharr/dispatcharr
container_name: dispatcharr_web
ports:
- 9191:9191
environment:
- DISPATHCARR_ENV=aio
- REDIS_HOST=localhost
- CELERY_BROKER_URL=redis://localhost:6379/0
volumes:
postgres_data:

View file

@ -0,0 +1,19 @@
services:
web:
# build:
# context: ..
# dockerfile: docker/Dockerfile.dev
image: dispatcharr/dispatcharr:dev
container_name: dispatcharr_web
ports:
- "5656:5656"
- 9191:9191
volumes:
- ../:/app
environment:
- DISPATHCARR_ENV=dev
- REDIS_HOST=localhost
- CELERY_BROKER_URL=redis://localhost:6379/0
volumes:
postgres_data:

View file

@ -1,18 +1,12 @@
services:
web:
build:
context: ..
dockerfile: docker/Dockerfile
image: dispatcharr/dispatcharr
container_name: dispatcharr_web
ports:
- "5656:5656"
- 9191:9191
depends_on:
- db
- redis
volumes:
- ../:/app
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
- POSTGRES_HOST=db
- POSTGRES_DB=dispatcharr
@ -21,17 +15,6 @@ services:
- REDIS_HOST=redis
- CELERY_BROKER_URL=redis://redis:6379/0
ui:
image: alpine
container_name: dispatcharr_ui
volumes:
- ../frontend:/app
extra_hosts:
- host.docker.internal:host-gateway
entrypoint: ["/bin/sh", "/app/entrypoint.sh"]
ports:
- "9191:9191"
celery:
build:
context: ..
@ -66,8 +49,8 @@ services:
- POSTGRES_DB=dispatcharr
- POSTGRES_USER=dispatch
- POSTGRES_PASSWORD=secret
# volumes:
# - postgres_data:/var/lib/postgresql/data
volumes:
- postgres_data:/var/lib/postgresql/data
redis:
image: redis:latest

18
docker/entrypoint.aio.sh Normal file
View file

@ -0,0 +1,18 @@
#!/bin/sh
# Check the value of DISPATCHARR_ENV and run the corresponding program
case "$DISPATCHARR_ENV" in
"dev")
echo "DISPATCHARR_ENV is set to 'dev'. Running Development Program..."
cd /app/frontend && npm install
exec /usr/sbin/uwsgi --ini uwsgi.dev.ini
;;
"aio")
echo "DISPATCHARR_ENV is set to 'aio'. Running All-in-One Program..."
exec /usr/sbin/uwsgi --ini uwsgi.aio.ini
;;
*)
echo "DISPATCHARR_ENV is not set or has an unexpected value. Running standalone..."
exec /usr/sbin/uwsgi --ini uwsgi.ini
;;
esac