Skip to content

Commit 9c66bda

Browse files
authored
Merge pull request #1 from jay-m-dev/add-alzkb-site
Add alzkb-site directory with neo4j and website
2 parents 4862f90 + 4d009a6 commit 9c66bda

40 files changed

+17043
-1
lines changed

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,12 @@ dmypy.json
234234
# Cython debug symbols
235235
cython_debug/
236236

237-
# End of https://www.toptal.com/developers/gitignore/api/python,macos,emacs,linux
237+
# End of https://www.toptal.com/developers/gitignore/api/python,macos,emacs,linux
238+
239+
# Ignore files from the alzkb-site
240+
node_modules
241+
default.conf
242+
*.dump
243+
*.key
244+
*.pem
245+
*.crt

alzkb-site/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

alzkb-site/.env_sample

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
COMPOSE_PROJECT_NAME=alzkb
2+
ALZKB_NEO4J_BROWSER_HTTP_PORT=7474
3+
ALZKB_NEO4J_BROWSER_HTTPS_PORT=7473
4+
ALZKB_APP_SERVICE=app
5+
ALZKB_PORT=5000
6+
ALZKB_DATA_ROOT=/data
7+
NEO4J_server_databases_default__to__read__only=true
8+
NEO4J_dbms_security_auth__enabled=false
9+
NEO4J_server_default__listen__address=0.0.0.0
10+
NEO4J_internal_dbms_cypher__ip__blocklist=0.0.0.0/0,::/0
11+
NEO4J_dbms_security_allow__csv__import__from__file__urls=false
12+
NEO4J_dbms_security_procedures_allowlist=gds.*,apoc.algo.*,apoc.atomic.*,apoc.bolt.*,apoc.case,apoc.cluster.*apoc.coll.*,apoc.config.*,apoc.convert.*,apoc.couchbase.*,apoc.create.*,apoc.custom.*,apoc.cypher.*,apoc.date.*,apoc.diff.*,apoc.do.*,apoc.dv.*,apoc.es.*,apoc.example.*,apoc.export.*,apoc.generate.*,apoc.gephi.*,apoc.get.*,apoc.graph.*,apoc.help,apoc.import.*,apoc.json.*,apoc.lock.*,apoc.log.*,apoc.math.*,apoc.merge.*,apoc.meta.*,apoc.metrics.*,apoc.model.*,apoc.mongo.*,apoc.mongodb.*,apoc.monitor.*,apoc.neighbors.*,apoc.nlp.*,apoc.nodes.*,apoc.path.*,apoc.periodic.*,apoc.redis.*,apoc.refactor.*,apoc.schema.*,apoc.search.*,apoc.spatial.*,apoc.static.*,apoc.stats.*,apoc.systemdb.*,apoc.text.*,apoc.trigger.*,apoc.ttl.*,apoc.util.*,apoc.uuid.*,apoc.warmup.*,apoc.when,apoc.xml.*
13+
# dbms.security.procedures.unrestricted is added automatically when the plugins are installed on the docker image
14+
NEO4J_dbms_security_procedures_unrestricted=gds.*,apoc.*
15+
NEO4J_server_directories_import=/var/lib/neo4j/import
16+
NEO4J_server_directories_data=/var/lib/neo4j/data
17+
NEO4J_server_directories_logs=/var/lib/neo4j/logs
18+
NEO4J_server_directories_plugins=/var/lib/neo4j/plugins
19+
NEO4J_PLUGINS='["apoc", "graph-data-science", "n10s"]'
20+
############################################################################################################
21+
# PRODUCTION SETTINGS
22+
# - uncomment the following lines in production
23+
# - comment the corresponding lines in development
24+
# ##########################################################################################################
25+
# ALZKB_HOST=alzkb.ai
26+
# ALZKB_HOST2=www.alzkb.ai
27+
# ALIRO_HOST=aliro.ai
28+
# ALIRO_HOST2=www.aliro.ai
29+
# ALZKB_NEO4J_BROWSER=neo4j.alzkb.ai
30+
# ALZKB_CERT=cert_file_name
31+
# ALZKB_CERT_KEY=cert_key_file_name
32+
# ALIRO_CERT=cert_file_name
33+
# ALIRO_CERT_KEY=cert_key_file_name
34+
# NEO4J_server_memory_heap_initial__size=1G
35+
# NEO4J_server_memory_heap_max__size=8G
36+
# NEO4J_server_default__advertised__address=neo4j.alzkb.ai
37+
# NEO4J_server_http_enabled=false
38+
# NEO4J_server_https_enabled=true
39+
# NEO4J_server_bolt_tls__level=OPTIONAL
40+
# NEO4J_dbms_ssl_policy_https_enabled=true
41+
# NEO4J_dbms_ssl_policy_https_base__directory==certificates/https
42+
# NEO4J_dbms_ssl_policy_https_private__key=cert_key_file_name
43+
# NEO4J_dbms_ssl_policy_https_public__certificate=cert_file_name
44+
# NEO4J_dbms_ssl_policy_https_client__auth=NONE
45+
# NEO4J_dbms_ssl_policy_bolt_enabled=true
46+
# NEO4J_dbms_ssl_policy_bolt_base__directory=certificates/bolt
47+
# NEO4J_dbms_ssl_policy_bolt_private__key=cert_key_file_name
48+
# NEO4J_dbms_ssl_policy_bolt_public__certificate=cert_file_name
49+
# NEO4J_dbms_ssl_policy_bolt_client__auth=NONE
50+
# NEO4J_browser_remote__content__hostname__whitelist=*
51+
# NEO4J_browser_post__connect__cmd=guide intro;play https://${ALZKB_HOST}/alzkb;play https://${ALZKB_HOST}/samples
52+
# NODE_ENV=prod
53+
############################################################################################################
54+
# DEVELOPMENT SETTINGS
55+
# - uncomment the following lines in development
56+
# - comment the corresponding lines in production
57+
# ##########################################################################################################
58+
ALZKB_HOST=127.0.0.1
59+
ALZKB_HOST2=localhost
60+
ALIRO_HOST=localhost
61+
ALIRO_HOST2=localhost
62+
ALZKB_NEO4J_BROWSER=127.0.0.1
63+
# # SSL is not used in development
64+
# # so these lines are should not be uncommented
65+
# # ALZKB_CERT=cert_file_name
66+
# # ALZKB_CERT_KEY=cert_key_file_name
67+
# # ALIRO_CERT=cert_file_name
68+
# # ALIRO_CERT_KEY=cert_key_file_name
69+
NEO4J_server_default__advertised__address=localhost
70+
NEO4J_server_http_enabled=true
71+
NEO4J_server_https_enabled=false
72+
NEO4J_browser_post__connect__cmd=guide intro
73+
NODE_ENV=dev

alzkb-site/.eslintrc.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true
5+
},
6+
extends: [
7+
'standard'
8+
],
9+
parserOptions: {
10+
ecmaVersion: 'latest',
11+
sourceType: 'module'
12+
},
13+
rules: {
14+
}
15+
}

alzkb-site/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Alzheimer's Knowledgebase (AlzKB) Site
2+
This repository is comprised of the following components:
3+
4+
- **Website**: site with some general information about this project. The source code for this website is found in the `app` directory
5+
6+
- **Neo4j**: used to store the graph database for this Knowledgebase.
7+
8+
- **Nginx**: used as a reverse proxy for the Website and the Neo4j Browser
9+
10+
- **Docker Compose files**
11+
- The `.yml` files contain definitions for building a docker image.
12+
13+
- **Environmental Variables**
14+
- The environmental variables in .env_sample are used by the different docker services.
15+
16+
# Installation
17+
## Prerequisites
18+
**Docker**
19+
- Automated Installation
20+
- Run `install-docker.sh` to install **Docker Engine**
21+
- Manual Installation
22+
- Install either [**Docker Desktop**](https://www.docker.com/products/docker-desktop/) or [**Docker Engine**](https://docs.docker.com/engine/getstarted/step_one/) based on your needs.
23+
- [**Docker Compose**](https://docs.docker.com/compose/install/)
24+
## Building and Running
25+
### Building and deploying all services
26+
1. Get a dump file of the database [here](https://upenn.box.com/s/dalcofa8i7rkkc2h2n6bfg8nvmwi83pq) and put this file in **neo4j/dump/**, make sure the filename is alzkb.dump (rename it if necessary)
27+
2. Copy the **.env_sample** as **.env** and set the variable values as needed for your environment.
28+
3. **On the very first run**, uncomment the lines for the neo4j-admin service in the docker-compose.yml file, after the first run, the neo4j-admin service is not needed.
29+
4. To deploy the Website, Neo4j, Nginx and dump the database into neo4j run: `docker compose up -d --build`
30+
### Building and deploying the services independently
31+
The services can be built independently of each other as needed.
32+
**First**, copy the **.env_sample** as **.env** and update the variable values as needed for your environment.
33+
- Website
34+
- Run `docker compose -f ./app.yml up -d --build`
35+
- Load the database dump
36+
1. Ensure that the neo4j docker container is not running, it must be stopped if it is.
37+
2. Get a dump file of the database [here](https://upenn.box.com/s/dalcofa8i7rkkc2h2n6bfg8nvmwi83pq) and put this file in **neo4j/dump/**, make sure the filename is alzkb.dump (rename it if necessary)
38+
3. Run `docker compose -f ./neo4j-admin.yml up -d --build`
39+
- Neo4j
40+
- Run `docker compose -f ./neo4j.yml up -d --build`
41+
- Nginx
42+
- Run `docker compose -f ./nginx.yml up -d --build`
43+
## Environmental Variables
44+
The **.env_sample** file contains the following environmental variables:
45+
- `COMPOSE_PROJECT_NAME` Base name of this project.
46+
- See the docker [documentation](https://docs.docker.com/compose/reference/envvars/) for more details.
47+
- `ALZKB_HOST` IP address (or URL) of the host server where the **Website** will be deployed.
48+
- `ALZKB_NEO4J_BROWSER` URL used for the Neo4J Browser, (may be different from `ALZKB_HOST`)
49+
- `ALZKB_APP_SERVICE` Name of the docker service where the **Website** will run. This value is used by Nginx to forward requests to this service.
50+
- `ALZKB_PORT` Port used by ExpressJS to serve the **Website**, Nginx will forward requests to `ALZKB_HOST` to this port.
51+
- `ALZKB_DATA_ROOT` Directory where the data from **Neo4J** will be stored on the host machine (data, logs, etc.)
52+
- `NEO4J_*` variables to configure Neo4j
53+
- For more information about these varibales, see the neo4j.conf [documenation](https://neo4j.com/docs/operations-manual/5/configuration/neo4j-conf/).
54+
- More details about how these variables map to the neo4j.conf file can be found [here](https://neo4j.com/docs/operations-manual/current/docker/configuration/)
55+
- `NODE_ENV` Set to either **prod** or **dev**
56+
- see [here](https://docs.npmjs.com/cli/v8/commands/npm-install) for more details.

alzkb-site/app.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: ./app
7+
env_file: .env
8+
ports:
9+
- 5000:5000

alzkb-site/app/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
npm-debug.log

alzkb-site/app/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM node:18.12.1-bullseye-slim
2+
# FROM node:latest
3+
4+
# Create app directory
5+
WORKDIR /usr/src/app
6+
7+
# Install app dependencies
8+
# Copy both package.json and package-lock.json
9+
COPY package*.json ./
10+
11+
RUN npm install
12+
RUN npm install pm2 --location=global
13+
14+
# Bundle app source
15+
COPY . .
16+
17+
CMD ["pm2-runtime", "alzkb.js"]

alzkb-site/app/alzkb.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const express = require('express')
2+
require('dotenv').config()
3+
// const path = require('path')
4+
const config = require('./config/config')
5+
6+
const app = express()
7+
const cors = require('cors')
8+
const compression = require('compression')
9+
// const helmet = require('helmet')
10+
// const ejs = require('ejs')
11+
require('ejs')
12+
13+
app.use(cors())
14+
app.use(compression())
15+
app.use(express.static('public', { maxAge: 3600000 }))
16+
app.set('view engine', 'ejs')
17+
// app.use(helmet())
18+
19+
app.get('/', (req, res) => {
20+
res.render('alzkb', config)
21+
})
22+
23+
app.get('/about', (req, res) => {
24+
res.render('about', config)
25+
})
26+
27+
app.get('/alzkb', (req, res) => {
28+
res.render('alzkb_about')
29+
})
30+
31+
app.get('/samples', (req, res) => {
32+
res.render('samples')
33+
})
34+
35+
app.listen(process.env.ALZKB_PORT, () => {
36+
console.log("port", process.env.ALZKB_PORT)
37+
})

alzkb-site/app/config/config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const config = {
2+
dev: {
3+
neo_browser: 'http://' + process.env.ALZKB_NEO4J_BROWSER + ':' + process.env.ALZKB_NEO4J_BROWSER_HTTP_PORT + '/browser/',
4+
},
5+
prod: {
6+
neo_browser: 'https://' + process.env.ALZKB_NEO4J_BROWSER + '/browser/'
7+
}
8+
}
9+
10+
if (process.env.NODE_ENV === "prod") {
11+
module.exports = config.prod
12+
} else {
13+
module.exports = config.dev
14+
}

0 commit comments

Comments
 (0)