Skip to content

Commit

Permalink
V0.0.3 documentation updates (openpredictionmarkets#220)
Browse files Browse the repository at this point in the history
* Starting documentation updates.

* Updating.

* Adding suggestion about how to re-do database on local.

* Update, evolving prod documentation.

* Updating documentation.
  • Loading branch information
pwdel authored Jul 31, 2024
1 parent 640a0ae commit b5cf08c
Show file tree
Hide file tree
Showing 12 changed files with 366 additions and 306 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## README/ Contents

- [Info on Local Setup](/README/LOCAL_SETUP.md)
- [Info on Market Mathematics](/README/README-MATH.md)
- [Info on Market Mathematics](/README/MATH/README-MATH.md)
- [Info on How Economics Can Be Customized](/README/README-CONFIG.md)
- [Info on Development Conventions](/README/README-CONVENTIONS.md)
- [Info on Feature Roadmap](/README/README-ROADMAP.md)
- [Info on Feature Roadmap](/README/PROJECT_MANAGEMENT/README-ROADMAP.md)

# About SocialPredict

Expand Down
233 changes: 0 additions & 233 deletions README/DEV_DEPLOY.md

This file was deleted.

Binary file removed README/DEV_DEPLOY_IMG/Route53_Hosted_Zone.png
Binary file not shown.
Binary file removed README/DEV_DEPLOY_IMG/Route53_Nameservers.png
Binary file not shown.
82 changes: 49 additions & 33 deletions README/LOCAL_SETUP.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## Repo Purpose

WARNING: As of the time of writing this LOCAL_SETUP document, 2 July 2024, this repo is designed for usage in development version on a local machine. Of course it can be adapted to run in production and is a part of the roadmap, but this is not fully supported yet.

For more information about the project go to: [SocialPredict](https://github.com/openpredictionmarkets/socialpredict)

### Supported Systems
Expand All @@ -13,55 +11,73 @@ Currently, the project is supported on Ubuntu up to 23.10 LTS and MacOS. Windows
- **Clone the Repository**: Download the repository to your local machine.
-- `git clone https://github.com/openpredictionmarkets/socialpredict.git`
- **Install Docker**: Install Docker on your local machine. [Here is the link to the Docker installation guide.](https://docs.docker.com/get-docker/) We are assuming the latest version of Docker as of the date of this document. Windows users will need to follow the instructions for installing Docker on WSL2. [Here is the link to set up the Docker Desktop backend on WSL2.](https://docs.docker.com/desktop/wsl/)
- **Install docker-compose**: Install docker-compose on your local machine. [Here is the link to the docker-compose installation guide](https://docs.docker.com/compose/install/). We are assuming the latest version of docker-compose as of the date of this document.
- **Install docker compose**: Install `docker compose` on your local machine. [Here is the link to the docker compose installation guide](https://docs.docker.com/compose/install/). We are assuming the latest version of docker compose as of the date of this document. NOTE: `docker-compose` is deprecated and the command to use should be `docker compose`.
- Within the root of the `./socialpredict` repo, run the command, `./SocialPredict install`.
- Select (2) Development, then select to rebuild the `.env` file and rebuild the imgages.
- When this has completed, run `./SocialPredict up`...this will use `docker compose` to spin up the images into containers on your machine.
- Once this is fully up and running, you can then visit `localhost` and log in to use the app.

### Backend Setup:
#### Use the following login credentials:

- Navigate to the `backend/` directory in your terminal.
- Run `./builddockerfile` to build and tag the Dockerfile.
- Access the API at `localhost` in your browser
- Sign in with the following Username/Password:
- Username: `admin`
- Password: `password`

### Frontend Setup:
### Shutting down the service:

- Navigate to the `frontend/` directory in your terminal.
- Run `./builddockerfile` to build and tag the Dockerfile.
- To shut down the service, navigate to the `./socialpredict` root directory in your terminal.
- Run `./SocialPredict down`, which will use `docker compose down` to stop services.
- The data in the database will be maintained for the next run.

### Nginx Setup:
### Development Tools and Troubleshooting

- Navigate to the `nginx/` directory in your terminal.
- Run `./builddockerfile` to build and tag the Dockerfile.
#### Entering a Container

### Database Seeding:
##### Database

- The database is seeded in the `/backend/main.go` with the lines:
* Log into the psql service directly:

```
// Seed the users
seed.SeedUsers(db)
seed.SeedMarket(db)
docker exec -it -e PGPASSWORD=password socialpredict-postgres-container psql -U user -d socialpredict_db
```

- If you wish not to seed markets or users, you can coment out those lines.
* The postgres data is stored locally at `./data/postgres` and is mounted by `./scripts/docker-compose-dev.yaml` with:

### Running the Service:
```
volumes:
- ../data/postgres:/var/lib/postgresql/data
```

- Navigate back to the root directory `socialpredict/` in your terminal.
- Run `./compose-dev` to spin up the service on Docker and open a port. Access the service at `localhost:8089`.
* The database on dev can be completely deleted and rebooted with the following, from `./` (root):

### Use the following login credentials:
1. `./SocialPredict down`
2. `rm -rf ./data/postgres/*`
3. `./SocialPredict up`

- Username: user1, Password: password
- Username: user2, Password: password
- Access the API at `localhost:8089`. API endpoints can be viewed [here](localhost:8089/api/v0/markets), using the pattern `localhost:8089/api/v0/markets` for example.
##### Getting Logs from Different Containers

### Shutting down the service:
* There are different containers which serve different purposes in our app, and `docker compose` is used to spin them all up and hook them together. If something goes wrong in the app, you can use a `docker compose -p scripts logs` command to view logs from all of the containers.

* However, there are tons and tons of logs, so to be able to look at logs from a specific container, you should add `| grep {whatever}` where `wherever` is the container in question, to filter your logs to see what the problem may have been.

- To shut down the service, navigate to the `socialpredict/` directory in your terminal.
Run `./compose-dev-down` to destroy the databases and fully shut down the service.
```
docker compose -p scripts logs | grep backend
```

* Errors from the `backend` container can be viewed by adding the `|` (pipe) and then `grep backend`, which is a way of filtering any lines which include, "backend," in them.

* Likewise, frontend, nginx, database, certbot errors can be filtered out similarly with:

```
docker compose -p scripts logs | grep frontend
docker compose -p scripts logs | grep nginx
docker compose -p scripts logs | grep postgres
docker compose -p scripts logs | grep certbot
```

### Development Tools
### Setting Up a Staging Instance On the Web

- In the main directory, there are three scripts:
While we don't like to say we have an official, "prod," version yet per se, we do give the ability for you to run an staging instance online which for all intents and purposes is a functioning web app. However we don't endorse this app as being completely secure and recoverable without extra work. We're working on getting SocialPredict in a more reliable, secure state.

* `./postgres-exec`
* `./postgres-backend`
* `./postgres-frontend`
See [Stage Setup](/README/STAGE_SETUP.md)
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit b5cf08c

Please sign in to comment.