wjbmattingly commited on
Commit
d2f9d2f
·
verified ·
1 Parent(s): e031063

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -4
Dockerfile CHANGED
@@ -39,7 +39,7 @@ RUN mkdir -p /app/media/imports /app/staticfiles /app/logs
39
  # Create custom settings for no-auth mode
40
  RUN echo 'from .settings import *\n\
41
  \n\
42
- # Disable authentication requirements\n\
43
  REST_FRAMEWORK = {\n\
44
  "DEFAULT_AUTHENTICATION_CLASSES": [],\n\
45
  "DEFAULT_PERMISSION_CLASSES": [\n\
@@ -69,24 +69,28 @@ CACHES = {\n\
69
  }\n\
70
  }\n\
71
  \n\
72
- # Disable user-related middleware\n\
73
  MIDDLEWARE = [\n\
74
  "corsheaders.middleware.CorsMiddleware",\n\
75
  "django.middleware.security.SecurityMiddleware",\n\
76
  "django.contrib.sessions.middleware.SessionMiddleware",\n\
77
  "django.middleware.common.CommonMiddleware",\n\
78
  "django.middleware.csrf.CsrfViewMiddleware",\n\
 
79
  "django.contrib.messages.middleware.MessageMiddleware",\n\
80
  "django.middleware.clickjacking.XFrameOptionsMiddleware",\n\
81
  ]\n\
82
  \n\
83
- # Remove auth-related apps\n\
84
  INSTALLED_APPS = [\n\
 
 
85
  "django.contrib.contenttypes",\n\
86
  "django.contrib.sessions",\n\
87
  "django.contrib.messages",\n\
88
  "django.contrib.staticfiles",\n\
89
  "rest_framework",\n\
 
90
  "corsheaders",\n\
91
  "ocr_app",\n\
92
  ]\n\
@@ -110,7 +114,7 @@ from django.views.generic import TemplateView\n\
110
  from django.contrib.staticfiles.urls import staticfiles_urlpatterns\n\
111
  \n\
112
  urlpatterns = [\n\
113
- # API endpoints (no auth required)\n\
114
  path("api/", include("ocr_app.urls")),\n\
115
  \n\
116
  # Frontend routes (single-page application)\n\
@@ -139,6 +143,16 @@ export DJANGO_SETTINGS_MODULE=vlamy_ocr.settings_no_auth\n\
139
  # Replace the main urls.py with no-auth version\n\
140
  cp /app/vlamy_ocr/urls_no_auth.py /app/vlamy_ocr/urls.py\n\
141
  \n\
 
 
 
 
 
 
 
 
 
 
142
  # Start the Django development server\n\
143
  python manage.py runserver 0.0.0.0:$PORT\n\
144
  ' > /app/start.sh && chmod +x /app/start.sh
 
39
  # Create custom settings for no-auth mode
40
  RUN echo 'from .settings import *\n\
41
  \n\
42
+ # Disable authentication requirements but keep auth apps for model dependencies\n\
43
  REST_FRAMEWORK = {\n\
44
  "DEFAULT_AUTHENTICATION_CLASSES": [],\n\
45
  "DEFAULT_PERMISSION_CLASSES": [\n\
 
69
  }\n\
70
  }\n\
71
  \n\
72
+ # Keep auth middleware but disable auth requirements\n\
73
  MIDDLEWARE = [\n\
74
  "corsheaders.middleware.CorsMiddleware",\n\
75
  "django.middleware.security.SecurityMiddleware",\n\
76
  "django.contrib.sessions.middleware.SessionMiddleware",\n\
77
  "django.middleware.common.CommonMiddleware",\n\
78
  "django.middleware.csrf.CsrfViewMiddleware",\n\
79
+ "django.contrib.auth.middleware.AuthenticationMiddleware",\n\
80
  "django.contrib.messages.middleware.MessageMiddleware",\n\
81
  "django.middleware.clickjacking.XFrameOptionsMiddleware",\n\
82
  ]\n\
83
  \n\
84
+ # Keep all apps installed to avoid model dependency issues\n\
85
  INSTALLED_APPS = [\n\
86
+ "django.contrib.admin",\n\
87
+ "django.contrib.auth",\n\
88
  "django.contrib.contenttypes",\n\
89
  "django.contrib.sessions",\n\
90
  "django.contrib.messages",\n\
91
  "django.contrib.staticfiles",\n\
92
  "rest_framework",\n\
93
+ "rest_framework.authtoken",\n\
94
  "corsheaders",\n\
95
  "ocr_app",\n\
96
  ]\n\
 
114
  from django.contrib.staticfiles.urls import staticfiles_urlpatterns\n\
115
  \n\
116
  urlpatterns = [\n\
117
+ # API endpoints (no auth required - permissions handled by settings)\n\
118
  path("api/", include("ocr_app.urls")),\n\
119
  \n\
120
  # Frontend routes (single-page application)\n\
 
143
  # Replace the main urls.py with no-auth version\n\
144
  cp /app/vlamy_ocr/urls_no_auth.py /app/vlamy_ocr/urls.py\n\
145
  \n\
146
+ # Run migrations for in-memory database (required for each startup)\n\
147
+ python manage.py migrate --noinput\n\
148
+ \n\
149
+ # Create a default anonymous user for the session\n\
150
+ python manage.py shell -c "\n\
151
+ from django.contrib.auth.models import User;\n\
152
+ if not User.objects.filter(username=\"anonymous\").exists():\n\
153
+ User.objects.create_user(\"anonymous\", \"[email protected]\", \"anonymous\")\n\
154
+ "\n\
155
+ \n\
156
  # Start the Django development server\n\
157
  python manage.py runserver 0.0.0.0:$PORT\n\
158
  ' > /app/start.sh && chmod +x /app/start.sh