diff --git a/Dockerfile b/Dockerfile index 815e7dc..85e6490 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ COPY . /app # Optional non-root user (not used as default to allow cron) RUN useradd -ms /bin/bash app && chown -R app:app /app -# USER app # keep running as root to manage cron +# USER app # Runtime env defaults ENV DJANGO_DEBUG=true \ diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index d4fed4f..0795da0 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,8 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -# Wait for potential dependencies (none for sqlite) - # Apply migrations python manage.py migrate --noinput @@ -20,19 +18,11 @@ username = os.environ['ADMIN_USERNAME'] password = os.environ['ADMIN_PASSWORD'] email = os.environ.get('ADMIN_EMAIL') or f"{username}@local" user, created = User.objects.get_or_create(username=username, defaults={'email': email}) -if created: - user.set_password(password) - user.is_superuser = True - user.is_staff = True - user.is_admin = True - user.save() -else: - # update password if user exists - user.set_password(password) - user.is_superuser = True - user.is_staff = True - user.is_admin = True - user.save() +user.set_password(password) +user.is_superuser = True +user.is_staff = True +user.is_admin = True +user.save() print("Admin ready") PY fi @@ -75,14 +65,14 @@ s.save() print("AppSettings seeded from environment (if provided)") PY -# Start cron for periodic job if schedule is set +# Setup cron if schedule provided if [[ -n "${CRON_SCHEDULE:-}" ]]; then - echo "Setting cron schedule: ${CRON_SCHEDULE}" - # write cronjob to user crontab - CRONLINE="${CRON_SCHEDULE} cd /app && /usr/local/bin/python manage.py check_new_media >> /app/cron.log 2>&1" - (crontab -l 2>/dev/null; echo "$CRONLINE") | crontab - - crond + echo "Configuring cron: ${CRON_SCHEDULE}" + echo "${CRON_SCHEDULE} cd /app && /usr/local/bin/python manage.py check_new_media >> /app/cron.log 2>&1" > /etc/cron.d/subscribarr + chmod 0644 /etc/cron.d/subscribarr + crontab /etc/cron.d/subscribarr + /usr/sbin/cron fi -# Start server +# Run server exec python manage.py runserver 0.0.0.0:8000 diff --git a/subscribarr/settings.py b/subscribarr/settings.py index 8fc606b..ed8ac30 100644 --- a/subscribarr/settings.py +++ b/subscribarr/settings.py @@ -120,7 +120,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/5.2/howto/static-files/ -STATIC_URL = 'static/' +STATIC_URL = '/static/' STATICFILES_DIRS = [BASE_DIR / 'static'] # STATIC_ROOT could be set for collectstatic in production # STATIC_ROOT = BASE_DIR / 'staticfiles'