diff --git a/Dockerfile b/Dockerfile index 0505072..f8a3100 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -# VERSION 0.1 +# VERSION 0.2 # AUTHOR: Nicholas Long -# DESCRIPTION: Dockerfile for running BuildingSync Website +# DESCRIPTION: Dockerfile for running BuildingSync Website with Python 3.9+ # TO_BUILD_AND_RUN: docker-compose build && docker-compose up -FROM alpine:3.10 +FROM alpine:3.18 RUN apk add --no-cache python3 \ python3-dev \ @@ -21,13 +21,12 @@ RUN apk add --no-cache python3 \ rm -r /usr/lib/python*/ensurepip && \ ln -sf /usr/bin/pip3 /usr/bin/pip && \ pip install --upgrade pip setuptools && \ - pip install git+https://github.com/Supervisor/supervisor@837c159ae51f3 && \ + pip install supervisor==4.2.5 && \ mkdir -p /var/log/supervisord/ && \ rm -r /root/.cache && \ addgroup -g 1000 uwsgi && \ adduser -G uwsgi -H -u 1000 -S uwsgi && \ mkdir -p /run/nginx && \ - echo "daemon off;" >> /etc/nginx/nginx.conf && \ rm -f /etc/nginx/conf.d/default.conf && \ echo "gem: --no-rdoc --no-ri" > /etc/gemrc @@ -48,9 +47,8 @@ COPY . /srv/buildingsync-website/ ### Copy the wait-for-it command to /usr/local COPY /docker/wait-for-it.sh /usr/local/wait-for-it.sh -# nginx configurations - alpine doesn't use the sites-available directory. Put the buildingsync -# website configuration file into the /etc/nginx/conf.d/ folder. -COPY /docker/nginx.conf /etc/nginx/conf.d/buildingsync-website.conf +# nginx configurations - replace the main nginx.conf with our custom configuration +COPY /docker/nginx.conf /etc/nginx/nginx.conf # Supervisor looks in /etc/supervisor for the configuration file. COPY /docker/supervisord.conf /etc/supervisor/supervisord.conf diff --git a/README.md b/README.md index c9ce62a..d23022d 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ This is the repository for the BuildingSync Validator web application. 1. Clone the repository. 1. Setup python 3. You can use a virtual environment: ```bash - pyenv install 3.6.5 - pyenv virtualenv 3.6.5 bsync-validator-3.6.5 - pyenv local bsync-validator-3.6.5 + pyenv install 3.9.23 + pyenv virtualenv 3.9.23 bsync-validator-3.9.23 + pyenv local bsync-validator-3.9.23 ``` 1. Install PostgreSQL server for local development (if desired) - Once installed, create your local database and user: @@ -50,7 +50,7 @@ This is the repository for the BuildingSync Validator web application. - To test schema import, you can run this command: ```bash - python manage.py reset_schema --schema_version=1.0.0 + python manage.py reset_schema --schema_version=2.6.0 ``` **NOTE**: You will need to be _off_ the NREL VPN to import a schema, otherwise you'll get an error related to http://www.gbxml.org/schema}Area' as the gbXML schema cannot be imported when on the NREL VPN. @@ -84,14 +84,6 @@ pre-commit run --all-files coverage report ``` -### Precommit - -- Run the following command to clean up your code before committing: - -```bash -pre-commit run --all-files -``` - ## Usage ### BuildingSync Schema @@ -255,7 +247,7 @@ To parse and map a new BEDES version: python manage.py bedes --schema_version=X.X.X --bedes_version=X.X ``` - Note that the bedes_version contains a v, ex: v2.2. + Note that the bedes_version contains a `v`, ex: v2.2. This will create a bedes_vX.X.json`file in the lib/bedes/vX.X directory. It will also create 2 CSV files:`bedes-mappings-enumerations.csv`and`bedes-mappings-terms.csv` in the lib/bedes/vX.X/schemaX.X directory. _Note_ — The BEDES terms must be mapped for each version of the BuildingSync schema by calling the python manage.py bedes` command above. @@ -309,6 +301,7 @@ Follow these steps to add new example tables from the TestSuite repo 1. The relevant files are currently on the `develop` branch of the [TestSuite](https://github.com/BuildingSync/TestSuite/tree/develop) repo. Clone the repo locally. 1. OpenStudio Simulation use case schematron files include patterns from a [library of schematron files](https://github.com/BuildingSync/TestSuite/tree/develop/lib). Copy these files from the TestSuite repo into the selection-tool at the following location: `bsyncviewer/testsuitelib`. 1. Open the relevant use case file from the TestSuite repo. For example: [L00_OpenStudio_Simulation.sch](https://github.com/BuildingSync/TestSuite/blob/develop/schematron/v2.2.0/v2-2-0_L000_OpenStudio_Simulation.sch). Edit the include statements at the top of the file with relative paths to the buildingsync-website testsuitelib directory. Save the file. + ```bash @@ -319,10 +312,11 @@ Follow these steps to add new example tables from the TestSuite repo ``` -1. Add the use case to the selection-tool by browsing to the `/use_cases` URL and clicking the _New Use Case_ button. + +2. Add the use case to the selection-tool by browsing to the `/use_cases` URL and clicking the _New Use Case_ button. 1. Fill out the name, description, and schema version - 1. Upload the file that was modified in the previous step - 1. Save -1. Make the use case public from the selection-tool admin interface. -1. If you have any example files to add to the selection-tool (for example, for the L000 OpenStudio Simulation use case, there are [2 examples files](https://github.com/BuildingSync/TestSuite/tree/develop/spec/use_cases/schema2.0.0/examples)), add them in the appropriate schema directory in `bsyncviewer/lib/validator/examples`. Regenerate the `example_files.zip` archive. This will make the files available as examples at the `/validator` URL. -1. You can now validate XMLs against the new use case. + 2. Upload the file that was modified in the previous step + 3. Save +3. Make the use case public from the selection-tool admin interface. +4. If you have any example files to add to the selection-tool (for example, for the L000 OpenStudio Simulation use case, there are [2 examples files](https://github.com/BuildingSync/TestSuite/tree/develop/spec/use_cases/schema2.0.0/examples)), add them in the appropriate schema directory in `bsyncviewer/lib/validator/examples`. Regenerate the `example_files.zip` archive. This will make the files available as examples at the `/validator` URL. +5. You can now validate XMLs against the new use case. diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 23f1f05..783f9a3 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,7 +1,7 @@ # Docker Compose creates multiple containers on a single machine. # Usage: # docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -version: "3" + services: web: command: python3 manage.py runserver 0.0.0.0:80 diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index c84dbec..193ff92 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -12,7 +12,6 @@ # BUILDINGSYNC_WEBSITE_ADMIN_PASSWORD # SECRET_KEY -version: "3" services: db-postgres: image: postgres:11.1 diff --git a/docker-compose.yml b/docker-compose.yml index f8a10ee..98a0c65 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,5 @@ # Docker Compose creates multiple containers on a single machine. # run `docker-compose up` to create and run/link the containers -version: "3" services: db-postgres: image: postgres:11.1 diff --git a/docker/nginx.conf b/docker/nginx.conf index 90116ad..96baebb 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -1,42 +1,60 @@ -# the upstream component nginx needs to connect to -upstream buildingsync_website_upsteam { - # server 127.0.0.1:8080; - server unix:///tmp/uwsgi-buildingsync-website.sock; +user nginx; +worker_processes auto; +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; +daemon off; + +events { + worker_connections 1024; } -# configuration of the server -server { - listen 80 default_server; - server_name localhost; - charset utf-8; +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + keepalive_timeout 65; + + # configuration of the server + server { + listen 80; + server_name localhost; + charset utf-8; - # increase the timeouts (large files can take awhile to upload) - # These are probably not needed, but increasing anyway - proxy_connect_timeout 600; - proxy_send_timeout 600; - proxy_read_timeout 600; - send_timeout 600; + # increase the timeouts (large files can take awhile to upload) + # These are probably not needed, but increasing anyway + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + send_timeout 600; - # max upload size - client_max_body_size 75M; # adjust to taste - client_body_timeout 6000; + # max upload size + client_max_body_size 75M; # adjust to taste + client_body_timeout 6000; - location = /favicon.ico { access_log off; log_not_found off; } - location /media { - alias /srv/buildingsync-website/bsyncviewer/media; - } - location /static { - alias /srv/buildingsync-website/bsyncviewer/collected_static; - } - location /documentation/ { - alias /srv/buildingsync-website/bsyncviewer/media/generated_docs/; - try_files $uri.html =404; - } + location = /favicon.ico { access_log off; log_not_found off; } + location /media { + alias /srv/buildingsync-website/bsyncviewer/media; + } + location /static { + alias /srv/buildingsync-website/bsyncviewer/collected_static; + } + location /documentation/ { + alias /srv/buildingsync-website/bsyncviewer/media/generated_docs/; + try_files $uri.html =404; + } - location / { - uwsgi_pass buildingsync_website_upsteam; - uwsgi_read_timeout 600; - uwsgi_send_timeout 600; - include /etc/nginx/uwsgi_params; + location / { + uwsgi_pass unix:///tmp/uwsgi-buildingsync-website.sock; + uwsgi_read_timeout 600; + uwsgi_send_timeout 600; + include /etc/nginx/uwsgi_params; + } } } diff --git a/docker/start_server.sh b/docker/start_server.sh index 77511c7..6097c83 100755 --- a/docker/start_server.sh +++ b/docker/start_server.sh @@ -10,8 +10,8 @@ echo "Waiting for postgres to start" ./manage.py collectstatic --noinput # Check if a schema has been imported -./manage.py reset_schema --schema_version 1.0.0 -./manage.py bedes --schema_version=1.0.0 --bedes_version=v2.2 --save_to_db +./manage.py reset_schema --schema_version 2.6.0 +./manage.py bedes --schema_version=2.6.0 --bedes_version=v2.5 --save_to_db # Create the default user based on the env vars echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('${BUILDINGSYNC_WEBSITE_ADMIN_USER}', '${BUILDINGSYNC_WEBSITE_ADMIN_EMAIL}', '${BUILDINGSYNC_WEBSITE_ADMIN_PASSWORD}')" | python manage.py shell