fix docker-django/cron problem
This commit is contained in:
		| @@ -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 \ | ||||
|   | ||||
| @@ -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,14 +18,6 @@ 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 | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user