Skip to content

Commit

Permalink
Use multi compose and settings files for example project (similar to …
Browse files Browse the repository at this point in the history
…ADIT and RADIS itself)
  • Loading branch information
medihack authored Jun 29, 2024
1 parent ee22f77 commit c816f82
Show file tree
Hide file tree
Showing 18 changed files with 652 additions and 246 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[dockercompose]": {
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[dockerfile]": {
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
Expand Down
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,23 @@ RUN poetry install
# Install requirements for end-to-end testing
RUN playwright install --with-deps chromium

# Required folders for web service
RUN mkdir -p /var/www/web/logs \
/var/www/web/static \
/var/www/web/ssl

# will become mountpoint of our code
WORKDIR /app


# `production` image used for runtime
FROM python-base as production
COPY --from=builder-base $PYSETUP_PATH $PYSETUP_PATH
COPY . /app/

# Required folders for web service
RUN mkdir -p /var/www/web/logs \
/var/www/web/static \
/var/www/web/ssl

WORKDIR /app
49 changes: 48 additions & 1 deletion adit_radis_shared/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import time
from typing import Callable
from typing import Callable, Generator

import pytest
from django.db import connection
from django_test_migrations.migrator import Migrator
from playwright.sync_api import Locator, Page, Response

from adit_radis_shared.accounts.factories import UserFactory
Expand Down Expand Up @@ -61,3 +63,48 @@ def _create_and_login_user(server_url: str):
return user

return _create_and_login_user


@pytest.fixture
def migrator(migrator: Migrator) -> Generator[Migrator, None, None]:
yield migrator

# We have to manually cleanup the Procrastinate tables, functions and types
# as otherwise the reset of django_test_migrations will fail
# See https://github.com/procrastinate-org/procrastinate/issues/1090
with connection.cursor() as cursor:
cursor.execute("""
DO $$
DECLARE
prefix text := 'procrastinate';
BEGIN
-- Drop tables
EXECUTE (
SELECT string_agg('DROP TABLE IF EXISTS ' || quote_ident(tablename)
|| ' CASCADE;', ' ')
FROM pg_tables
WHERE tablename LIKE prefix || '%'
);
-- Drop functions
EXECUTE (
SELECT string_agg(
'DROP FUNCTION IF EXISTS ' || quote_ident(n.nspname) || '.'
|| quote_ident(p.proname) || '('
|| pg_catalog.pg_get_function_identity_arguments(p.oid) || ') CASCADE;',
' '
)
FROM pg_proc p
LEFT JOIN pg_namespace n ON n.oid = p.pronamespace
WHERE p.proname LIKE prefix || '%'
);
-- Drop types
EXECUTE (
SELECT string_agg('DROP TYPE IF EXISTS ' || quote_ident(typname)
|| ' CASCADE;', ' ')
FROM pg_type
WHERE typname LIKE prefix || '%'
);
END $$;
""")
Loading

0 comments on commit c816f82

Please sign in to comment.