Skip to content

Commit

Permalink
Beta release 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
thesethtruth authored Apr 26, 2023
2 parents 66aa240 + d5c8fea commit 3e679f0
Show file tree
Hide file tree
Showing 141 changed files with 34,994 additions and 105,196 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ DB_PASSWORD=postgres
DB_HOST=db
DB_PORT=5432

## uncomment DSN to opt-in to Sentry
# SENTRY_DSN=https://764e9f2b886741bcbcfd2acd74a7f7b0@o4505045746384896.ingest.sentry.io/4505045759361024
SENTRY_ENVIRONMENT=devcontainer

#FRONTEND

NEXT_PUBLIC_WAGTAIL_API_URL=http://localhost:8000/wt/api/nextjs
Expand Down
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Actual behavior**
A clear and concise description of what actually happened.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.

**Add labels**
- [ ] Correct label for origin (e.g. `bug` of `feature enhancement` of `nice to have`)
- [ ] Correcte label voor categorie (e.g. `interactive element configuratie`)
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ htmlcov
# Mypy
.mypy_cache
.devcontainer/.env
docker-compose.prod.local.yml
docker-compose.prod.local.yml
frontend/.env
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2022-2023 Quintel Intelligence B.V., Witteveen+Bos Raadgevende ingenieurs B.V., ZEnMo Simulations B.V.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 0 additions & 28 deletions Makefile

This file was deleted.

100 changes: 97 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
# Holon-wagtail
# Holon webapp

# Holon web application prototype
This repo contains the webapp part of the HOLON project. This includes the NextJS frontend and the Django/Wagtail backend. This repo and other repos are licensed under the [MIT license](LICENSE.md). Other repos are:

Prototype of the Holon web application
1. [AnyLogic](https://github.com/ZEnMo/HOLON)
2. [ETM service](https://github.com/ZEnMo/HOLON-ETM)
3. [cloudclient](https://github.com/ZEnMo/HOLON-cloudclient) (legacy)

## Content

- [Holon webapp](#holon-webapp)
- [Content](#content)
- [Environments](#environments)
- [First setup / Start the application](#first-setup--start-the-application)
- [Start Dev Container](#start-dev-container)
- [Configure stuff inside the container](#configure-stuff-inside-the-container)
- [Admin](#admin)
- [Integration testing environment (pizza)](#integration-testing-environment-pizza)
- [Initial deploy](#initial-deploy)
- [Refresh](#refresh)
- [Update the snapshot](#update-the-snapshot)
- [Deployment](#deployment)
- [Datamodel](#datamodel)
- [Development on datamodel](#development-on-datamodel)
- [Resetting database and building project](#resetting-database-and-building-project)

## Environments

We work using LTAP. Local runs on dev containers (see below). All TAP environments are automatically built containers that are hosted on Azure webapp instances. In addition, we have a bleeding edge Integration Testing (IT) environment.

## First setup / Start the application

Expand Down Expand Up @@ -73,6 +97,76 @@ python manage.py createsuperuser

After finishing all the steps, you can login on localhost:8000/admin

## Integration testing environment (pizza)

Runs on Hetzner cloud instance. Uses the acceptance static&media CDN.

### Initial deploy

1. Set DNS and certify domain

```bash
# ~/HOLON-webapp
sudo certbot certonly
# copy both privkey.pem and fullchain.pem
cp <cert-location> ./docker/files/certs
```

2. Copy environment variable files and set correct value

```bash
# ~/HOLON-webapp
```

Make sure the following env vars are set:

```bash
# To be set manually
SECRET_KEY
AZURE_STORAGE_KEY

# With default value (check if applicable)
ALLOWED_HOSTS=*
DOMAIN_HOST="https://pizzaoven.holontool.nl"
AZURE_ACCOUNT_NAME=holonstorage
CUSTOM_STATIC_LOCATION="static-acceptatie"
CUSTOM_MEDIA_LOCATION="media-acceptatie"
```

**make sure to set the CORS settings at the blob storage, otherwise errors will occur**

3. Make an export of the production database (or the one that you want to sync) and place that file as `prod.sql` in the `db` folder.
1. Use docker compose up to start the service

```bash
docker compose up
```

### Refresh

Checkout to the branch that you want to use. Stop the Python service, rebuild and restart the service

```bash
docker compose stop python
docker compose build python
docker compose up -d python
```

### Update the snapshot

1. Remove the database container (will remove all data!)

```bash
docker compose rm db
```

2. Place the new `dump.sql` as `prod.sql` in the `db` folder.
3. Restart using `docker compose up`

```bash
docker compose up
```

## Deployment

Deployment is automatically done with GitHub actions to the Azure portal, the following mapping between code and azure is done:
Expand Down
4 changes: 4 additions & 0 deletions db/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM postgres:12 as db
WORKDIR /app
COPY init.sh /docker-entrypoint-initdb.d
COPY prod.sql /scripts/db/dump.sql
1 change: 1 addition & 0 deletions db/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
psql -U $POSTGRES_USER -d $POSTGRES_DB -a -f /scripts/db/dump.sql >/dev/null
18 changes: 0 additions & 18 deletions docker-compose.override.local.yml

This file was deleted.

26 changes: 0 additions & 26 deletions docker-compose.prod.yml

This file was deleted.

42 changes: 23 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,56 @@ services:
image: nginx:alpine
working_dir: /app
ports:
- "8000:80"
- "8082:443"
- "80:80"
- "443:443"
depends_on:
- python
volumes:
- "./docker/files/static/502.html:/app/502.html:cached"
- "./docker/files/config/nginx.conf.template:/etc/nginx/templates/default.conf.template:cached"
- "./docker/files/static/502.html:/app/502.html"
- "./docker/files/config/nginx.pizza.conf:/etc/nginx/templates/default.conf.template"
- "./docker/files/certs:/etc/nginx/certs"
- "./src/media:/app/media"
- "./src/static:/app/static"
environment:
- PYTHON_HOST=http://python
- NEXT_HOST=http://next
- MEDIA_REMOTE_DOMAIN=holontool.nl
- SERVER_NAME=pizzaoven.holontool.nl
extra_hosts:
- "host.docker.internal:host-gateway"

next:
image: holon_nextjs
build: ./frontend
build:
context: ./frontend
dockerfile: Dockerfile.prod
ports:
- "3000:3000"
volumes:
- ./frontend:/usr/src/app
- /usr/src/frontend/node_modules
- /usr/src/frontend/.next
depends_on:
- web
environment:
- WAGTAIL_API_URL=http://python:8000/wt/
- NEXT_PUBLIC_WAGTAIL_API_URL=https://pizzaoven.holontool.nl/wt/api/nextjs
- NEXT_PUBLIC_BASE_URL=https://pizzaoven.holontool.nl/wt

python:
image: holon_wagtail_python
build: ./src
build:
context: ./src
dockerfile: Dockerfile.prod
volumes:
- "./src:/app"
depends_on:
- db
env_file: ./docker/config/python.env

db:
image: postgis/postgis:12-2.5-alpine
image: prod_db
volumes:
- postgres-data:/var/lib/postgresql/data
build:
context: ./db
ports:
- "8083:5432"
volumes:
- "./docker/files/db-dumps/:/docker-entrypoint-initdb.d/"
- "./docker/files/shared:/shared:rw"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres

volumes:
postgres-data:
3 changes: 2 additions & 1 deletion docker/config/python.example.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ DEBUG_TOOLBAR=True
DB_NAME=postgres
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=db
DB_HOST=db
SENTRY_ENVIRONMENT=
17 changes: 17 additions & 0 deletions docker/config/python.pizza.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_BUCKET_NAME=
VS_CODE_REMOTE_DEBUG=False
DEBUG_TOOLBAR=True
DB_NAME=postgres
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=db
ALLOWED_HOSTS=*
DOMAIN_HOST="https://pizzaoven.holontool.nl"
AZURE_ACCOUNT_NAME=holonstorage
CUSTOM_STATIC_LOCATION="static-acceptatie"
CUSTOM_MEDIA_LOCATION="media-acceptatie"
SECRET_KEY=
AZURE_STORAGE_KEY=
SENTRY_ENVIRONMENT=pizzaoven
12 changes: 1 addition & 11 deletions docker/files/config/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ server {
send_timeout 120s; # timeout for sending a response to the requesting client - note this isn't proxy_send_timeout, but the time between two successive write operations to the requesting client (ie. browser)
reset_timedout_connection on;

server_name holontool.nl _;
server_name ${SERVER_NAME} _;

client_max_body_size 128M;

Expand All @@ -33,16 +33,6 @@ server {
alias /app/media;
}

# If you instead want to use images from a remote domain - uncomment this
# location /wt/media {
# try_files $uri @fallback;
# }
#
# location @fallback {
# resolver 1.1.1.1;
# rewrite "^/wt/media/(.*)$" "https://${MEDIA_REMOTE_DOMAIN}/wt/media/$1" redirect;
# }

location /wt/static/ {
expires 30d;
autoindex off;
Expand Down
Loading

0 comments on commit 3e679f0

Please sign in to comment.