Skip to content

Commit

Permalink
Merge pull request buildingSMART#85 from buildingSMART/main
Browse files Browse the repository at this point in the history
Sync main back to development
  • Loading branch information
civilx64 authored Jul 24, 2024
2 parents 050d1e3 + b934d13 commit b05488c
Show file tree
Hide file tree
Showing 26 changed files with 104 additions and 63 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# .dockerignore file for docker compose
**/.env
**/.dev
**/.ssh
**/.DS_Store
Expand Down
17 changes: 9 additions & 8 deletions .env
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# variables in Docker Compose
VERSION = v0.6.4
VERSION = 0.6.5
DEBUG = True
ENV = Development
PUBLIC_URL = https://dev.validate.buildingsmart.org
PUBLIC_URL = http://localhost

# Django
MEDIA_ROOT = /files_storage
DJANGO_DB = postgresql
DJANGO_SECRET_KEY = django-insecure-um7-^+&jbk_=80*xcc9uf4nh$4koida7)ja&6!vb*$8@n288jk
DJANGO_ALLOWED_HOSTS = dev.validate.buildingsmart.org
DJANGO_TRUSTED_ORIGINS = https://dev.validate.buildingsmart.org https://authentication.buildingsmart.org
DJANGO_ALLOWED_HOSTS = localhost
DJANGO_TRUSTED_ORIGINS = http://localhost:3000 http://localhost http://localhost:8000
DJANGO_LOG_LEVEL = INFO
DJANGO_GUNICORN_WORKERS = 3
DJANGO_GUNICORN_THREADS_PER_WORKER = 4
Expand All @@ -31,15 +31,16 @@ DJANGO_DB_USER_CONTEXT = SYSTEM
CELERY_CONCURRENCY = 4

# Email
MAILGUN_API_URL = https://api.eu.mailgun.net/v3/validate.buildingsmart.org/messages
MAILGUN_API_KEY = <API_KEY>
MAILGUN_API_URL = <MG_API_URL>
MAILGUN_API_KEY = <MG_API_KEY>
MAILGUN_FROM_NAME = Validation Service
MAILGUN_FROM_EMAIL = noreply@validate.buildingsmart.org
MAILGUN_FROM_EMAIL = noreply@localhost
ADMIN_EMAIL = noreply@localhost
CONTACT_EMAIL = noreply@localhost

# IAM
B2C_CLIENT_ID = <B2C_CLIENT_ID>
B2C_CLIENT_SECRET = <B2C_CLIENT_SECRET>
B2C_AUTHORITY = <B2C_AUTHORITY>
B2C_USER_FLOW = <B2C_USER_FLOW>
B2C_USER_FLOW = <B2C_USER_FLOW>
USE_WHITELIST = False
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
VERSION=v0.6.4

none:
@echo ERROR: Enter at least one target (start, start-load-balanced, start-full, start-infra-only, stop, build, rebuild, clean, fetch-modules)

Expand Down Expand Up @@ -36,18 +34,22 @@ rebuild: clean

rebuild-frontend:
docker stop frontend || true
docker rmi --force buildingsmart/validationsvc-frontend:${VERSION}
docker rmi --force $$(docker images -q 'buildingsmart/validationsvc-frontend' | uniq) || true
docker compose build

rebuild-backend:
docker stop backend || true
docker stop worker || true
docker rmi --force buildingsmart/validationsvc-backend:${VERSION}
docker rmi --force $$(docker images -q 'buildingsmart/validationsvc-backend' | uniq) || true
docker compose build

clean:
docker compose down
docker image prune --force
docker stop backend || true
docker stop worker || true
docker stop frontend || true
docker rmi --force $$(docker images -q 'buildingsmart/validationsvc-frontend' | uniq) || true
docker rmi --force $$(docker images -q 'buildingsmart/validationsvc-backend' | uniq) || true
docker image prune --all --force --filter=label=org.opencontainers.image.vendor="buildingSMART.org"
docker system prune --all --force --volumes --filter=label=org.opencontainers.image.vendor="buildingSMART.org"

fetch-modules:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ exit
6. Navigate to different services:

- Validation Service - React UI: http://localhost
- Django Admin UI: http://localhost/admin (or http://localhost:8000/admin) - default user/password: root/root
- Django Admin UI: http://localhost/admin - default user/password per step 5.
- Django API - Swagger: http://localhost/api/swagger-ui
- Django API - Redoc: http://localhost/api/redoc

Expand Down Expand Up @@ -168,6 +168,8 @@ npm run start
```shell
cd backend

. .dev/venv/bin/activate

DJANGO_SUPERUSER_USERNAME=root DJANGO_SUPERUSER_PASSWORD=root DJANGO_SUPERUSER_EMAIL=root@localhost python3 manage.py createsuperuser --noinput

DJANGO_SUPERUSER_USERNAME=SYSTEM DJANGO_SUPERUSER_PASSWORD=system DJANGO_SUPERUSER_EMAIL=system@localhost python3 manage.py createsuperuser --noinput
Expand All @@ -176,7 +178,7 @@ DJANGO_SUPERUSER_USERNAME=SYSTEM DJANGO_SUPERUSER_PASSWORD=system DJANGO_SUPERUS
9. Navigate to different services:

- Validation Service - React UI: http://localhost:3000
- Django Admin UI: http://localhost:8000/admin - default user/password: root/root
- Django Admin UI: http://localhost:8000/admin - default user/password per step 8
- Django API - Swagger: http://localhost:8000/api/swagger-ui
- Django API - Redoc: http://localhost:8000/api/redoc
- Celery Flower UI: http://localhost:5555
Expand Down
17 changes: 12 additions & 5 deletions backend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# 4) host environment variables
# 5) default value in code

VERSION = 0.6.4
VERSION = 0.6.5
DEBUG = True
ENV = Development
PUBLIC_URL = http://localhost:3000
Expand Down Expand Up @@ -37,9 +37,16 @@ TASK_TIMEOUT_LIMIT = 3600
DJANGO_DB_USER_CONTEXT = SYSTEM

# Email
MAILGUN_API_URL = https://api.eu.mailgun.net/v3/validate.buildingsmart.org/messages
MAILGUN_API_KEY = <API_KEY>
MAILGUN_API_URL = <MG_API_URL>
MAILGUN_API_KEY = <MG_API_KEY>
MAILGUN_FROM_NAME = Validation Service
MAILGUN_FROM_EMAIL = noreply@validate.buildingsmart.org
MAILGUN_FROM_EMAIL = noreply@localhost
ADMIN_EMAIL = noreply@localhost
CONTACT_EMAIL = noreply@localhost
CONTACT_EMAIL = noreply@localhost

# IAM
B2C_CLIENT_ID = <B2C_CLIENT_ID>
B2C_CLIENT_SECRET = <B2C_CLIENT_SECRET>
B2C_AUTHORITY = <B2C_AUTHORITY>
B2C_USER_FLOW = <B2C_USER_FLOW>
USE_WHITELIST = False
5 changes: 3 additions & 2 deletions backend/apps/ifc_validation/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.contrib import admin
from django.contrib import messages
from django.contrib.auth import get_permission_codename
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.http import HttpResponseRedirect
from django.shortcuts import render
Expand Down Expand Up @@ -315,7 +316,7 @@ class AuthoringToolAdmin(BaseAdmin):
list_filter = ["company", "created", "updated"]


class UserAdmin(BaseAdmin):
class CustomUserAdmin(UserAdmin):

list_display = ["id", "username", "email", "first_name", "last_name", "is_active", "is_staff", "is_superuser", "last_login", "date_joined"]
list_filter = ['is_staff', 'is_superuser', 'is_active']
Expand Down Expand Up @@ -348,4 +349,4 @@ def deactivate(self, request, queryset):
admin.site.register(AuthoringTool, AuthoringToolAdmin)

admin.site.unregister(User)
admin.site.register(User, UserAdmin)
admin.site.register(User, CustomUserAdmin)
2 changes: 1 addition & 1 deletion backend/apps/ifc_validation/checks/ifc_gherkin_rules
Submodule ifc_gherkin_rules updated 43 files
+3 −3 .github/workflows/ci.yml
+1 −1 features/ALA003_Alignment-same-segment-types-in-business-logic-and-geometry.feature
+37 −0 features/ALS011_Alignment-segment-entity-type-consistency.feature
+31 −0 features/ALS012_Alignment-segment-start-and-length-attribute-types.feature
+26 −0 features/GEM051_Presence-of-geometric-context.feature
+2 −2 features/OJT001_Object-predefined-type.feature
+2 −2 features/environment.py
+16 −1 features/steps/givens/entities.py
+52 −53 features/steps/thens/alignment.py
+14 −3 features/steps/thens/attributes.py
+23 −1 features/steps/thens/existance.py
+8 −17 features/steps/thens/values.py
+1 −1 features/steps/utils/ifc43x_alignment_validation/entities/helpers.py
+13 −2 features/steps/validation_handling.py
+1 −1 ifc_validation_models
+336 −3,076 test/files/ala003/pass-ala003-same_segment_geometry_types.ifc
+336 −3,076 test/files/ala003/pass-ala003-without_segmented_reference_curve.ifc
+5 −11 test/files/ala003/segment_type_mapping.md
+10 −0 test/files/als011/README.md
+263 −0 test/files/als011/fail-als011-scenario01-composite_curve_inconsistent_types.ifc
+263 −0 test/files/als011/fail-als011-scenario02-gradient_curve_composite_curve_segment.ifc
+364 −0 test/files/als011/fail-als011-scenario02-segmented_ref_curve_composite_curve_segment.ifc
+263 −0 test/files/als011/pass-als011-scenario01-consistent_types.ifc
+364 −0 test/files/als011/pass-als011-scenario02-correct_types.ifc
+11 −0 test/files/als012/README.md
+364 −0 test/files/als012/fail-als012-scenario01-composite_curve_wrong_segment_start_type.ifc
+364 −0 test/files/als012/fail-als012-scenario02-composite_curve_wrong_segment_length_type.ifc
+364 −0 test/files/als012/fail-als012-scenario03-gradient_curve_wrong_segment_start_type.ifc
+364 −0 test/files/als012/fail-als012-scenario04-gradient_curve_wrong_segment_length_type.ifc
+364 −0 test/files/als012/fail-als012-scenario05-segmented_reference_curve_wrong_segment_start_type.ifc
+364 −0 test/files/als012/fail-als012-scenario06-segmented_reference_curve_wrong_segment_length_type.ifc
+364 −0 test/files/als012/pass-als012-correct_segment_start_and_length_types.ifc
+413 −0 test/files/als012/pass-als012-incorrect_types_not_part_of_alignment.ifc
+12 −0 test/files/gem051/README.md
+30 −0 test/files/gem051/fail-gem051-scenario01-ifccontext_related_to_ifcrepresentationcontext.ifc
+29 −0 test/files/gem051/fail-gem051-scenario01-ifcproject_excludes_context.ifc
+30 −0 test/files/gem051/fail-gem051-scenario01-ifcproject_related_to_ifcrepresentationcontext.ifc
+29 −0 test/files/gem051/fail-gem051-scenario02-ifccontext_excludes_geomcontext.ifc
+29 −0 test/files/gem051/pass-gem051-scenario01-ifcproject_includes_context.ifc
+30 −0 test/files/gem051/pass-gem051-scenario01-ifcproject_includes_subtype_geomcontext.ifc
+29 −0 test/files/gem051/pass-gem051-scenario02-ifccontext_includes_geomcontext.ifc
+4 −4 test/files/ojt001/fail-ojt001-scenario03-typed_via_relation_and_at_occurrence.ifc
+1 −1 test/files/ojt001/pass-ojt001-scenario01-userdefined_w_object_type.ifc
8 changes: 5 additions & 3 deletions backend/apps/ifc_validation_bff/views_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

from apps.ifc_validation.tasks import ifc_file_validation_task

from core.settings import MEDIA_ROOT, DEVELOPMENT, LOGIN_URL, MAX_FILES_PER_UPLOAD
from core.settings import MEDIA_ROOT, MAX_FILES_PER_UPLOAD
from core.settings import DEVELOPMENT, LOGIN_URL, USE_WHITELIST

logger = logging.getLogger(__name__)

Expand All @@ -41,8 +42,9 @@ def get_current_user(request):

logger.info(f"Authenticated user with username = '{username}' via OAuth, user.id = {user.id}")
return user

elif DEVELOPMENT:

# only used for local development
elif DEVELOPMENT and not USE_WHITELIST:

username = 'development'
user = User.objects.all().filter(username=username).first()
Expand Down
3 changes: 3 additions & 0 deletions backend/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@
LOGIN_CALLBACK_URL = os.environ.get("CALLBACK_URL", f"{PUBLIC_URL}/callback")
POST_LOGIN_REDIRECT_URL = os.environ.get("POST_LOGIN_REDIRECT_URL", f"{PUBLIC_URL}/dashboard")

# whitelisting of users
USE_WHITELIST = os.environ.get("USE_WHITELIST", False)

AUTHLIB_OAUTH_CLIENTS = {
'b2c': {
'client_id': B2C_CLIENT_ID,
Expand Down
5 changes: 3 additions & 2 deletions backend/core/views_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from authlib.integrations.django_client import OAuth

from .email_tasks import send_user_registered_admin_email_task
from .settings import LOGIN_CALLBACK_URL, POST_LOGIN_REDIRECT_URL, LOGOUT_URL, LOGIN_URL, PRODUCTION
from .settings import LOGIN_CALLBACK_URL, POST_LOGIN_REDIRECT_URL, LOGOUT_URL, LOGIN_URL
from .settings import USE_WHITELIST

oauth = OAuth()
oauth.register(name="b2c")
Expand Down Expand Up @@ -51,7 +52,7 @@ def callback(request):
username = username,
password = username,
email = userinfo['email'],
is_active = True if PRODUCTION else False,
is_active = not USE_WHITELIST, # whitelisting of users
is_superuser = False,
is_staff = False,
first_name = userinfo['given_name'],
Expand Down
9 changes: 6 additions & 3 deletions docker-compose.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ services:
expose:
- 8000
environment:
PUBLIC_URL: ${PUBLIC_URL}
PUBLIC_URL: ${PUBLIC_URL} # for IAM links
ENV: ${ENV}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${CELERY_BROKER_URL}
CELERY_RESULT_BACKEND: "django-db"
Expand All @@ -52,7 +53,8 @@ services:
B2C_CLIENT_ID: ${B2C_CLIENT_ID}
B2C_CLIENT_SECRET: ${B2C_CLIENT_SECRET}
B2C_AUTHORITY: ${B2C_AUTHORITY}
B2C_USER_FLOW: ${B2C_USER_FLOW}
B2C_USER_FLOW: ${B2C_USER_FLOW}
USE_WHITELIST: ${USE_WHITELIST}
deploy: # example only
mode: replicated
replicas: 2
Expand All @@ -69,7 +71,8 @@ services:
volumes:
- files_data:/files_storage
environment:
PUBLIC_URL: ${PUBLIC_URL}
PUBLIC_URL: ${PUBLIC_URL} # for email links
ENV: ${ENV}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${CELERY_BROKER_URL}
CELERY_RESULT_BACKEND: "django-db"
Expand Down
9 changes: 6 additions & 3 deletions docker-compose.load_balanced.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ services:
expose:
- 8000
environment:
PUBLIC_URL: ${PUBLIC_URL}
PUBLIC_URL: ${PUBLIC_URL} # for IAM links
ENV: ${ENV}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${CELERY_BROKER_URL}
CELERY_RESULT_BACKEND: "django-db"
Expand All @@ -52,7 +53,8 @@ services:
B2C_CLIENT_ID: ${B2C_CLIENT_ID}
B2C_CLIENT_SECRET: ${B2C_CLIENT_SECRET}
B2C_AUTHORITY: ${B2C_AUTHORITY}
B2C_USER_FLOW: ${B2C_USER_FLOW}
B2C_USER_FLOW: ${B2C_USER_FLOW}
USE_WHITELIST: ${USE_WHITELIST}
deploy: # example only
mode: replicated
replicas: 2
Expand All @@ -73,7 +75,8 @@ services:
volumes:
- files_data:/files_storage
environment:
PUBLIC_URL: ${PUBLIC_URL}
PUBLIC_URL: ${PUBLIC_URL} # for email links
ENV: ${ENV}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${CELERY_BROKER_URL}
CELERY_RESULT_BACKEND: "django-db"
Expand Down
7 changes: 5 additions & 2 deletions docker-compose.nodb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ services:
ports:
- 8000:8000
environment:
PUBLIC_URL: ${PUBLIC_URL}
PUBLIC_URL: ${PUBLIC_URL} # for IAM links
ENV: ${ENV}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${CELERY_BROKER_URL}
CELERY_RESULT_BACKEND: "django-db"
Expand All @@ -54,6 +55,7 @@ services:
B2C_CLIENT_SECRET: ${B2C_CLIENT_SECRET}
B2C_AUTHORITY: ${B2C_AUTHORITY}
B2C_USER_FLOW: ${B2C_USER_FLOW}
USE_WHITELIST: ${USE_WHITELIST}
depends_on:
- redis

Expand All @@ -66,7 +68,8 @@ services:
volumes:
- files_data:/files_storage
environment:
PUBLIC_URL: ${PUBLIC_URL}
PUBLIC_URL: ${PUBLIC_URL} # for email links
ENV: ${ENV}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${CELERY_BROKER_URL}
CELERY_RESULT_BACKEND: "django-db"
Expand Down
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ services:
ports:
- 8000:8000
environment:
PUBLIC_URL: ${PUBLIC_URL}
PUBLIC_URL: ${PUBLIC_URL} # for IAM links
ENV: ${ENV}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${CELERY_BROKER_URL}
CELERY_RESULT_BACKEND: "django-db"
Expand All @@ -54,6 +55,7 @@ services:
B2C_CLIENT_SECRET: ${B2C_CLIENT_SECRET}
B2C_AUTHORITY: ${B2C_AUTHORITY}
B2C_USER_FLOW: ${B2C_USER_FLOW}
USE_WHITELIST: ${USE_WHITELIST}
depends_on:
- db
- redis
Expand All @@ -67,7 +69,8 @@ services:
volumes:
- files_data:/files_storage
environment:
PUBLIC_URL: ${PUBLIC_URL}
PUBLIC_URL: ${PUBLIC_URL} # for email links
ENV: ${ENV}
DEBUG: ${DEBUG}
CELERY_BROKER_URL: ${CELERY_BROKER_URL}
CELERY_RESULT_BACKEND: "django-db"
Expand Down
1 change: 1 addition & 0 deletions docker/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ RUN --mount=type=cache,target=/root/.cache \

# copy code
ADD ./backend /app/backend
RUN rm -f /app/backend/.env

# remove and download git submodules
RUN set -ex && \
Expand Down
4 changes: 1 addition & 3 deletions docker/frontend/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ README.md

dist
node_modules
build

.env
build
5 changes: 2 additions & 3 deletions docker/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COPY ./frontend/src ./src
COPY ./frontend/public ./public
COPY ./frontend/package* ./
COPY ./frontend/.env.* ./
COPY ./frontend/.env ./

# build React app
RUN npm install && \
Expand Down Expand Up @@ -47,6 +48,4 @@ LABEL org.opencontainers.image.title="IFC Validation Service - Frontend" \
org.opencontainers.image.url="https://github.com/buildingSMART/validate" \
org.opencontainers.image.licenses="MIT"
#org.opencontainers.image.version="{$VERSION}" TODO
#org.opencontainers.image.created="TODO"

#CMD "certbot --nginx -d dev.validate.buildingsmart.org -n && ./docker-entrypoint.sh"
#org.opencontainers.image.created="TODO"
2 changes: 1 addition & 1 deletion docker/frontend/nginx/default.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server {
listen 80;
server_name dev.validate.buildingsmart.org;
server_name _;
server_tokens off;

# turn off buffering, enable streaming to backend
Expand Down
1 change: 1 addition & 0 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_VERSION=$npm_package_version
4 changes: 2 additions & 2 deletions frontend/.env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PUBLIC_URL=https://dev.validate.buildingsmart.org
REACT_APP_FETCH_PATH=https://dev.validate.buildingsmart.org/bff
PUBLIC_URL=/
REACT_APP_FETCH_PATH=/bff
Loading

0 comments on commit b05488c

Please sign in to comment.