Skip to content

Commit 1bc3591

Browse files
authored
Fix the docker-compose serving (#694)
This fixes a grab bag of problems for me, but still doesn't get it to usability. The static files makes this render. And then the other changes address the errors in logs ``` dab_postgres | 2025-02-05 18:39:53.062 UTC [58] FATAL: role "$${POSTGRES_USER}" does not exist ``` and ``` test_app-1 | uwsgi_check_logrotate()/lseek(): Illegal seek [core/logging.c line 494] ``` This is addressed by the uwsgi config file change, and to the startup script. I think this is some progress, but unfortunately, I'm still blocked on using the docker-compose environment as I get a CSRF error when trying to log in.
1 parent 5b22f8e commit 1bc3591

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ tools/generated/*
4949

5050
# generated ssl certs
5151
compose/ingress/certs/*
52+
53+
# static files
54+
test_app/static_collected/

test_app/defaults.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,15 @@
148148
ANSIBLE_BASE_TEAM_MODEL = 'test_app.Team'
149149
ANSIBLE_BASE_ORGANIZATION_MODEL = 'test_app.Organization'
150150

151+
STATIC_ROOT = os.path.join(BASE_DIR, 'test_app', 'static_collected')
151152
STATIC_URL = '/static/'
152153

154+
STATICFILES_DIRS = [
155+
os.path.join(BASE_DIR, 'static'),
156+
]
157+
158+
CSRF_TRUSTED_ORIGINS = ['http://localhost', 'https://localhost']
159+
153160
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
154161

155162
SECRET_KEY = "asdf1234"

test_app/scripts/container_startup_uwsgi.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ echo "Read the custom settings file data just as a test"
1919
$DYNACONF -i test_app.settings.DYNACONF inspect -k JUST_A_TEST
2020

2121
$PYTHON manage.py migrate
22+
$PYTHON manage.py collectstatic --clear --noinput
2223
DJANGO_SUPERUSER_PASSWORD=password DJANGO_SUPERUSER_USERNAME=admin [email protected] $PYTHON manage.py createsuperuser --noinput || true
2324
$PYTHON manage.py authenticators --initialize
2425
$PYTHON manage.py create_demo_data

test_app/urls.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from django.conf import settings
2+
from django.conf.urls.static import static
13
from django.contrib import admin
24
from django.urls import include, path, re_path
35

@@ -22,4 +24,4 @@
2224
path('api/v1/timeout_view/', views.timeout_view, name='test-timeout-view'),
2325
path('login/', include('rest_framework.urls')),
2426
path("__debug__/", include("debug_toolbar.urls")),
25-
]
27+
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

test_app/uwsgi.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ chmod-socket = 660
77
vacuum = true
88

99
# Log to stdout
10-
logto = /dev/stdout
10+
# logto = /dev/stdout
1111
log-master = true
1212
#disable-logging = true
1313

tools/dev_postgres/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ ENV POSTGRES_PASSWORD=dabing
66

77
EXPOSE 5432
88

9-
HEALTHCHECK --interval=10s --timeout=5s --retries=5 CMD ["pg_isready", "-U", "$${POSTGRES_USER}", "-d", "$${POSTGRES_DB}"]
9+
HEALTHCHECK --interval=10s --timeout=5s --retries=5 CMD ["pg_isready", "-U", "dab", "-d", "dab_db"]

0 commit comments

Comments
 (0)