diff --git a/docker/Dockerfile b/docker/Dockerfile index b7fc0dcf..c33f24bf 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -24,6 +24,7 @@ RUN apt-get update && \ python -m pip install virtualenv && \ virtualenv /dispatcharrpy && \ git clone https://github.com/Dispatcharr/Dispatcharr /app && \ + cd /app && \ git checkout --track origin/uwsgi && \ cd /app && \ pip install --no-cache-dir -r requirements.txt && \ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 8a5ac8c1..32cf7ac0 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -50,8 +50,10 @@ fi chmod +x /etc/profile.d/dispatcharr.sh # Run init scripts -bash /app/docker/init/01-user-setup.sh -bash /app/docker/init/02-postgres.sh +echo "Starting init process..." +. /app/docker/init/01-user-setup.sh +. /app/docker/init/02-postgres.sh +. /app/docker/init/03-init-dispatcharr.sh # Start PostgreSQL echo "Starting Postgres..." @@ -65,11 +67,15 @@ postgres_pid=$(su - postgres -c "/usr/lib/postgresql/14/bin/pg_ctl -D /data stat echo "✅ Postgres started with PID $postgres_pid" pids+=("$postgres_pid") -echo "🚀 Starting nginx..." -nginx -nginx_pid=$(pgrep nginx | sort | head -n1) -echo "✅ nginx started with PID $nginx_pid" -pids+=("$nginx_pid") +if [ "$DISPATCHARR_ENV" = "dev" ]; then + . /app/docker/init/99-init-dev.sh +else + echo "🚀 Starting nginx..." + nginx + nginx_pid=$(pgrep nginx | sort | head -n1) + echo "✅ nginx started with PID $nginx_pid" + pids+=("$nginx_pid") +fi echo "🚀 Starting uwsgi..." su - $POSTGRES_USER -c "cd /app && uwsgi --ini /app/docker/uwsgi.ini &" diff --git a/docker/init/02-postgres.sh b/docker/init/02-postgres.sh index 36c76270..ddaa15b7 100644 --- a/docker/init/02-postgres.sh +++ b/docker/init/02-postgres.sh @@ -49,4 +49,7 @@ EOF fi kill $postgres_pid + while kill -0 $postgres_pid; do + sleep 1 + done fi diff --git a/docker/init/03-init-dispatcharr.sh b/docker/init/03-init-dispatcharr.sh index 87520a9e..55f697bc 100644 --- a/docker/init/03-init-dispatcharr.sh +++ b/docker/init/03-init-dispatcharr.sh @@ -3,4 +3,5 @@ # Required so both uwsgi and nginx (www-data) can use it # @TODO: change nginx to run as the same use as uwsgi touch /app/uwsgi.sock +chown -R $PUID:$PGID /app chmod 777 /app/uwsgi.sock diff --git a/docker/init/99-init-dev.sh b/docker/init/99-init-dev.sh new file mode 100644 index 00000000..a1f13aef --- /dev/null +++ b/docker/init/99-init-dev.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "🚀 Development Mode - Setting up Frontend..." + +# Install Node.js +if ! command -v node 2>&1 >/dev/null +then + echo "=== setting up nodejs ===" + curl -sL https://deb.nodesource.com/setup_23.x -o /tmp/nodesource_setup.sh + bash /tmp/nodesource_setup.sh + apt-get update + apt-get install -y --no-install-recommends \ + nodejs +fi + +# Install frontend dependencies +cd /app/frontend && npm install diff --git a/docker/uwsgi.ini b/docker/uwsgi.ini index 72f4d6ad..b4884b62 100644 --- a/docker/uwsgi.ini +++ b/docker/uwsgi.ini @@ -4,6 +4,7 @@ exec-pre-app = python manage.py migrate --noinput attach-daemon = celery -A dispatcharr worker -l info attach-daemon = redis-server +attach-daemon = cd /app/frontend && npm run start # Core settings chdir = /app