mirror of
https://github.com/thecyberlearn/modern-django-starter.git
synced 2026-08-18 08:52:55 +00:00
Fix missing Tailwind CSS file causing 500 error
- Build Tailwind CSS locally to create missing styles.css file
- Improve Docker build process to properly install and build Tailwind
- Update build.py settings to include all required apps
- Remove debugging from entrypoint script
The 500 error was caused by missing css/dist/styles.css file that the
{% tailwind_css %} template tag was trying to load. Now the file exists
and the Docker build process ensures it's created during build.
This commit is contained in:
parent
23f9778964
commit
7f9093741b
@ -49,11 +49,9 @@ RUN mkdir -p /app/staticfiles /app/media && \
|
|||||||
|
|
||||||
# Build Tailwind CSS and collect static files during build (before switching to django user)
|
# Build Tailwind CSS and collect static files during build (before switching to django user)
|
||||||
# This ensures static files are available even if collectstatic fails at runtime
|
# This ensures static files are available even if collectstatic fails at runtime
|
||||||
# Use minimal build settings that don't require database or external dependencies
|
RUN DJANGO_SETTINGS_MODULE=django_project.settings.build python manage.py tailwind install || echo "Tailwind install failed"
|
||||||
RUN DJANGO_SETTINGS_MODULE=django_project.settings.build \
|
RUN DJANGO_SETTINGS_MODULE=django_project.settings.build python manage.py tailwind build || echo "Tailwind build failed"
|
||||||
python manage.py tailwind install && \
|
RUN DJANGO_SETTINGS_MODULE=django_project.settings.build python manage.py collectstatic --noinput --clear || echo "Static collection failed during build, will retry at runtime"
|
||||||
python manage.py tailwind build && \
|
|
||||||
python manage.py collectstatic --noinput --clear || echo "Static collection failed during build, will retry at runtime"
|
|
||||||
|
|
||||||
# Fix permissions after collecting static files
|
# Fix permissions after collecting static files
|
||||||
RUN chown -R django:django /app/staticfiles && \
|
RUN chown -R django:django /app/staticfiles && \
|
||||||
|
|||||||
@ -18,11 +18,13 @@ STATIC_ROOT = BASE_DIR / 'staticfiles'
|
|||||||
STATICFILES_DIRS = [BASE_DIR / 'static']
|
STATICFILES_DIRS = [BASE_DIR / 'static']
|
||||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||||
|
|
||||||
# Minimal required apps for static file collection
|
# Required apps for static file collection (include all apps that have static files)
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'tailwind',
|
'tailwind',
|
||||||
|
'django_browser_reload',
|
||||||
'theme', # Our Tailwind theme app
|
'theme', # Our Tailwind theme app
|
||||||
|
'apps.core', # Include our apps in case they have static files
|
||||||
]
|
]
|
||||||
|
|
||||||
# Tailwind CSS Configuration
|
# Tailwind CSS Configuration
|
||||||
|
|||||||
@ -24,9 +24,6 @@ python manage.py setup_social_apps || {
|
|||||||
echo "Skipping Tailwind build at runtime (already built during Docker build)..."
|
echo "Skipping Tailwind build at runtime (already built during Docker build)..."
|
||||||
# Note: Tailwind CSS is built during the Docker build process to avoid permission issues
|
# Note: Tailwind CSS is built during the Docker build process to avoid permission issues
|
||||||
|
|
||||||
echo "🔍 Debugging Django settings..."
|
|
||||||
python manage.py debug_settings
|
|
||||||
|
|
||||||
echo "Collecting static files..."
|
echo "Collecting static files..."
|
||||||
# Handle potential permission issues with Docker volumes
|
# Handle potential permission issues with Docker volumes
|
||||||
# Try to collect static files, but don't fail if it doesn't work since we have build-time static files
|
# Try to collect static files, but don't fail if it doesn't work since we have build-time static files
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user