diff --git a/README.md b/README.md index a2b92789..a92cf380 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,22 @@ We are using Python 3.10 for the backend. Check out the [High-Level Protocol Architecture](https://www.notion.so/High-Level-Protocol-Architecture-6f1fd3551da74213b560ead369f132dc) +## End to End Demo + +If you are interested in just taking a look at the project. +You can set up an entire stack needed to run Open Assistant, including the +website, backend, and associated dependent services. + +To start the demo, run this, in root directory: + +```sh +docker compose up --build +``` + +Then, navigate to `http://localhost:3000` and interact with the website. When +logging in, navigate to `http://localhost:1080` to get the magic email login +link. + ### Website The website is built using Next.js and is in the `website` folder. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..014f44dc --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,100 @@ +version: "3.7" + +services: + # Use `docker compose up backend-dev` to start a database and work and the backend. + backend-dev: + image: tianon/true + depends_on: [db, adminer] + + # Use `docker compose up frontend-dev` to start all services needed to work on the frontend. + frontend-dev: + image: tianon/true + depends_on: [db, webdb, adminer, maildev, backend] + + # This DB is for the FastAPI Backend. + db: + image: postgres + restart: always + ports: + - 5432:5432 + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + healthcheck: + test: ["CMD", "pg_isready", "-U", "postgres"] + interval: 2s + timeout: 2s + retries: 10 + + # This DB is for Web Authentication and data caching. + webdb: + image: postgres + restart: always + ports: + - 5433:5432 + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: oasst_web + healthcheck: + test: ["CMD", "pg_isready", "-U", "postgres"] + interval: 2s + timeout: 2s + retries: 10 + + # This lets you manually inspect the web and backend databases. + adminer: + image: adminer + restart: always + ports: + - 8089:8080 + + # This fakes an SMTP email server used by website authentication. + # User registration emails can be found by going to localhost:1080 and + # opening the emails listed. + maildev: + image: maildev/maildev + restart: always + environment: + - MAILDEV_WEB_PORT=1080 + - MAILDEV_SMTP_PORT=1025 + ports: + - "1080:1080" + - "1025:1025" + + # The oassist backend service. + backend: + build: + dockerfile: docker/Dockerfile.backend + image: oasst-backend + environment: + - POSTGRES_HOST=db + - DEBUG_SKIP_API_KEY_CHECK=True + - MAX_WORKERS=1 + depends_on: + db: + condition: service_healthy + ports: + - "8080:8080" + + # The oassist web service. + web: + build: + dockerfile: docker/Dockerfile.website + image: oasst-web + environment: + - DATABASE_URL=postgres://postgres:postgres@webdb/oasst_web + - FASTAPI_URL=http://backend:8080 + - FASTAPI_KEY=1234 + - NEXTAUTH_SECRET=O/M2uIbGj+lDD2oyNa8ax4jEOJqCPJzO53UbWShmq98= + - EMAIL_SERVER_HOST=maildev + - EMAIL_SERVER_PORT=1025 + - EMAIL_FROM=info@example.com + - NEXTAUTH_URL=http://localhost:3000 + depends_on: + webdb: + condition: service_healthy + ports: + - "3000:3000" + command: bash wait-for-postgres.sh node server.js diff --git a/scripts/backend-development/README.md b/scripts/backend-development/README.md index 3f7e6509..30be253e 100644 --- a/scripts/backend-development/README.md +++ b/scripts/backend-development/README.md @@ -1,6 +1,6 @@ # Backend Development Setup -Run `docker compose up` to start a database. The default settings are already configured to connect to the database at `localhost:5432`. +In root directory, run `docker compose up backend-dev` to start a database. The default settings are already configured to connect to the database at `localhost:5432`. Make sure you have all requirements installed. You can do this by running `pip install -r requirements.txt` inside the `backend` folder and `pip install -e .` inside the `oasst-shared` folder. Then, run the backend using the `run-local.sh` script. This will start the backend server at `http://localhost:8080`. diff --git a/scripts/backend-development/docker-compose.yaml b/scripts/backend-development/docker-compose.yaml deleted file mode 100644 index 0445cf34..00000000 --- a/scripts/backend-development/docker-compose.yaml +++ /dev/null @@ -1,23 +0,0 @@ -version: "3.7" - -services: - db: - image: postgres - restart: always - ports: - - 5432:5432 - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: postgres - healthcheck: - test: ["CMD", "pg_isready", "-U", "postgres"] - interval: 2s - timeout: 2s - retries: 10 - - adminer: - image: adminer - restart: always - ports: - - 8089:8080 diff --git a/scripts/endtoend-demo/README.md b/scripts/endtoend-demo/README.md deleted file mode 100644 index 2d738453..00000000 --- a/scripts/endtoend-demo/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# End to End Demo - -This sets up an entire stack needed to run Open Assistant, including the -website, backend, and associated dependent services. - -To start the service, do the following: - -```sh -docker compose up --build -``` - -Then, navigate to `http://localhost:3000` and interact with the website. When -logging in, navigate to `http://localhost:1080` to get the magic email login -link. diff --git a/scripts/endtoend-demo/docker-compose.yaml b/scripts/endtoend-demo/docker-compose.yaml deleted file mode 100644 index 936e4a33..00000000 --- a/scripts/endtoend-demo/docker-compose.yaml +++ /dev/null @@ -1,58 +0,0 @@ -version: "3.7" - -services: - # This DB is for the FastAPI Backend. - db: - extends: - file: ../frontend-development/docker-compose.yaml - service: db - - # This DB is for Web Authentication and data caching. - webdb: - extends: - file: ../frontend-development/docker-compose.yaml - service: webdb - environment: - POSTGRES_DB: oasst_web - - # This lets you manually inspect the web and backend databases. - adminer: - extends: - file: ../frontend-development/docker-compose.yaml - service: adminer - - # This fakes an SMTP email server used by website authentication. - # User registration emails can be found by going to localhost:1080 and - # opening the emails listed. - maildev: - extends: - file: ../frontend-development/docker-compose.yaml - service: maildev - - # The oassist backend service. - backend: - extends: - file: ../frontend-development/docker-compose.yaml - service: backend - - # The oassist web service. - web: - build: - dockerfile: docker/Dockerfile.website - context: ../../ - image: oasst-web - environment: - - DATABASE_URL=postgres://postgres:postgres@webdb/oasst_web - - FASTAPI_URL=http://backend:8080 - - FASTAPI_KEY=1234 - - NEXTAUTH_SECRET=O/M2uIbGj+lDD2oyNa8ax4jEOJqCPJzO53UbWShmq98= - - EMAIL_SERVER_HOST=maildev - - EMAIL_SERVER_PORT=1025 - - EMAIL_FROM=info@example.com - - NEXTAUTH_URL=http://localhost:3000 - depends_on: - webdb: - condition: service_healthy - ports: - - "3000:3000" - command: bash wait-for-postgres.sh node server.js diff --git a/scripts/frontend-development/README.md b/scripts/frontend-development/README.md index e13e37c0..c0394694 100644 --- a/scripts/frontend-development/README.md +++ b/scripts/frontend-development/README.md @@ -1,5 +1,5 @@ # Frontend Development Setup -Run `docker compose up --build` to start a database and the backend server. +In root directory run `docker compose up frontend-dev --build` to start a database and the backend server. Then, point your frontend at `http://localhost:8080` to start developing. During development, any API key will be accepted. diff --git a/scripts/frontend-development/docker-compose.yaml b/scripts/frontend-development/docker-compose.yaml deleted file mode 100644 index e34c2d8f..00000000 --- a/scripts/frontend-development/docker-compose.yaml +++ /dev/null @@ -1,58 +0,0 @@ -version: "3.7" - -services: - # This DB is for the FastAPI Backend. - db: - extends: - file: ../backend-development/docker-compose.yaml - service: db - - # This DB is for Web Authentication and data caching. - webdb: - image: postgres - restart: always - ports: - - 5433:5432 - environment: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: ocgpt_website - healthcheck: - test: ["CMD", "pg_isready", "-U", "postgres"] - interval: 2s - timeout: 2s - retries: 10 - - # This lets you manually inspect the web and backend databases. - adminer: - extends: - file: ../backend-development/docker-compose.yaml - service: adminer - - backend: - build: - dockerfile: docker/Dockerfile.backend - context: ../.. - image: oasst-backend - environment: - - POSTGRES_HOST=db - - DEBUG_SKIP_API_KEY_CHECK=True - - MAX_WORKERS=1 - depends_on: - db: - condition: service_healthy - ports: - - "8080:8080" - - # This fakes an SMTP email server used by website authentication. - # User registration emails can be found by going to localhost:1080 and - # opening the emails listed. - maildev: - image: maildev/maildev - restart: always - environment: - - MAILDEV_WEB_PORT=1080 - - MAILDEV_SMTP_PORT=1025 - ports: - - "1080:1080" - - "1025:1025" diff --git a/scripts/frontend-development/run-bot-local.sh b/scripts/frontend-development/run-bot-local.sh index 7308c541..56833b0a 100755 --- a/scripts/frontend-development/run-bot-local.sh +++ b/scripts/frontend-development/run-bot-local.sh @@ -2,7 +2,7 @@ parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) # switch to bot directory -pushd "$parent_path/../../bot" +pushd "$parent_path/../../discord-bot" python3 __main__.py