|
1 | 1 | # Polis |
2 | 2 |
|
3 | | -Polis is an AI powered sentiment gathering platform. More organic than surveys and less effort than focus groups. |
| 3 | +> :warning: We are migrating to [New Implementation](https://github.com/MaanasArora/convergent/) -> [Chorus](https://github.com/choruslabs/chorus) and archiving this repo! |
4 | 4 |
|
5 | | -For a detailed methods paper, see [Polis: Scaling Deliberation by Mapping High Dimensional Opinion Spaces][methods-paper]. |
6 | | - |
7 | | - [methods-paper]: https://www.e-revistes.uji.es/index.php/recerca/article/view/5516/6558 |
| 5 | +Polis is an AI-powered sentiment gathering platform. More organic than surveys and less effort than focus groups. |
8 | 6 |
|
9 | 7 | <!-- Changes to badge text in URLs below, require changes to "name" value in .github/workflows/*.yml --> |
10 | 8 | [][docker-image-builds] |
11 | 9 | [][e2e-tests] |
12 | | -<img src="https://img.shields.io/liberapay/receives/ctto.polis.svg?logo=liberapay"> |
13 | 10 |
|
14 | 11 | [docker-image-builds]: https://hub.docker.com/u/newjerseystyle |
15 | 12 | [e2e-tests]: https://github.com/CivicTechTO/polis/actions?query=workflow%3A%22E2E+Tests%22 |
16 | 13 |
|
17 | | ---- |
18 | | - |
19 | | -## 🎈 🪁 Start here! 🪁 🎈 |
20 | | - |
21 | | -If you're interested in using or contributing to Polis, please see the following: |
22 | | - |
23 | | -- [📚 **knowledge base**][knowledge-base]: for a comprehensive wiki to help you understand and use the system |
24 | | -- [🌐 **main deployment**](https://pol.is): the main deployment of Polis is at <https://pol.is>, and is |
25 | | - free to use for nonprofits and government |
26 | | -- [💬 **discussions**][discussions]: for questions (QA) and discussion |
27 | | -- [✔️ **issues**][issues]: for well-defined technical issues |
28 | | -- [🏗️ **project board**][board]: somewhat incomplete, but still useful; We stopped around the time that Projects Beta came out, and we have a [Projects Beta Board][beta-board] that we'll eventually be migrating to |
29 | | -- [✉️ reach out][hello]: if you are applying Polis in a high-impact context, and need more help than you're able to get through the public channels above |
30 | | - |
31 | | - [knowledge-base]: https://compdemocracy.org/Welcome |
32 | | - [issues]: https://github.com/compdemocracy/polis/issues |
33 | | - [board]: https://github.com/compdemocracy/polis/projects/1 |
34 | | - [beta-board]: https://github.com/compdemocracy/polis/projects/1 |
35 | | - [discussions]: https://github.com/compdemocracy/polis/discussions |
36 | | - [hello]: mailto:hello@compdemocracy.org |
37 | | - |
38 | | -If you're trying to set up a Polis deployment or development environment, then please read the rest of this document 👇 ⬇️ 👇 |
39 | | - |
40 | | ---- |
41 | | - |
42 | | -## ⚡ Running Polis |
43 | | - |
44 | | -Polis comes with Docker infrastructure for running a complete system, whether for a [production deployment](#-production-deployment) or a [development environment](#-development-tooling) (details for each can be found in later sections of this document). |
45 | | -As a consequence, the only prerequisite to running Polis is that you install a recent `docker` (and Docker Desktop if you are on Mac or Windows). |
46 | 14 |
|
47 | | -If you aren't able to use Docker for some reason, the various Dockerfiles found in subdirectories (`math`, `server`, `*-client`) of this repository _can_ be used as a reference for how you'd set up a system manually. |
48 | | -If you're interested in doing the legwork to support alternative infrastructure, please [let us know in an issue](https://github.com/compdemocracy.org/issues). |
| 15 | +## What is Polis? |
49 | 16 |
|
50 | | -### Quick Start |
| 17 | +Polis is a platform for gathering, analyzing, and understanding sentiment at scale. It uses AI to help facilitate large-scale, open-ended discussions. |
51 | 18 |
|
52 | | -```sh |
53 | | -cp example.env .env |
54 | | -make start |
55 | | -``` |
| 19 | +* **For a detailed methods paper**, see [Polis: Scaling Deliberation by Mapping High Dimensional Opinion Spaces][methods-paper]. |
56 | 20 |
|
57 | | -That should run docker compose with the development overlay (see below) and default configuration values. |
| 21 | + [methods-paper]: https://www.e-revistes.uji.es/index.php/recerca/article/view/5516/6558 |
58 | 22 |
|
59 | | -Visit `localhost:80/createuser` and get started. |
| 23 | +## Quick Links 🪁 🎈 |
60 | 24 |
|
61 | | -### Docker & Docker Compose |
| 25 | +* **Main Deployment:** [https://pol.is](https://pol.is) (Free for nonprofits and governments) |
| 26 | +* **CivicTech Deployment (This Fork):** [https://civictech-polis.azurewebsites.net/](https://civictech-polis.azurewebsites.net/) |
| 27 | +* **Knowledge Base (Wiki):** [https://compdemocracy.org/Welcome](https://compdemocracy.org/Welcome) (Comprehensive user guide) |
| 28 | +* **Discussions (Q&A):** [https://github.com/compdemocracy/polis/discussions](https://github.com/compdemocracy/polis/discussions) |
| 29 | +* **Technical Issues:** [https://github.com/compdemocracy/polis/issues](https://github.com/compdemocracy/polis/issues) |
| 30 | +* **High-Impact Support:** <mailto:hello@compdemocracy.org> (For significant deployments requiring more support) |
| 31 | +* **Community Support:** [https://github.com/CivicTechTO/polis/issues](https://github.com/CivicTechTO/polis/issues) |
| 32 | +* **Talk to a person / Polis 101** : [https://civictech.ca](https://civictech.ca) (Join CivicTech Hacknight - Ask for a Polis 101) |
| 33 | +* **CivicTech Slack:** [https://civictech.ca](https://civictech.ca) (Join the `#polis` channel) |
62 | 34 |
|
63 | | -Newer versions of `docker` have `docker compose` built in as a subcommand. |
64 | | -If you are using an older version (and don't want to upgrade), you'll need to separately install `docker-compose`, and use that instead in the instructions that follow. |
65 | | -Note however that the newer `docker compose` command is required to [take advantage of Docker Swarm](/docs/scaling#docker-compose-over-docker-swarm) as a scaling option. |
66 | 35 |
|
67 | | -Many convenient commands are found in the Makefile. Run `make help` for a list of available commands. |
| 36 | +## Getting Started (For Developers & Deployers) |
68 | 37 |
|
69 | | -### Building and running the containers |
| 38 | +This section is for those who want to run their own instance of the CivicTech fork of Polis or contribute to development. |
70 | 39 |
|
71 | | -First clone the repository, then navigate via command line to the root directory and run the following command to build and run the docker containers. |
| 40 | +Polis comes with Docker infrastructure for running a complete system, whether for a [production deployment](#docs/deployment.md#-production-deployment) or a [development environment](#-development-mode). |
72 | 41 |
|
73 | | -Copy the example.env file and modify as needed (although it should just work as is for development and testing purposes). |
| 42 | +### Quick Start (Development) |
74 | 43 |
|
| 44 | +Open terminal and enter: |
75 | 45 | ```sh |
76 | 46 | cp example.env .env |
77 | | -``` |
78 | | - |
79 | | - |
80 | | -```sh |
81 | | -docker compose --profile postgres up --build |
82 | | -``` |
83 | | - |
84 | | -If you get a permission error, try running this command with `sudo`. |
85 | | -If this fixes the problem, sudo will be necessary for all other commands as well. |
86 | | -To avoid having to use `sudo` in the future (on a Linux or Windows machine with WSL), [you can follow setup instructions here.](https://docs.docker.com/engine/install/linux-postinstall/) |
87 | | - |
88 | | -Once you've built the docker images, you can run without `--build`, which may be faster. Run |
89 | | - |
90 | | -```sh |
91 | | -docker compose --profile postgres up |
92 | | -``` |
93 | | - |
94 | | -or simply |
95 | | - |
96 | | -```sh |
97 | 47 | make start |
98 | 48 | ``` |
99 | 49 |
|
100 | | -Any time you want to _rebuild_ the images, just reaffix `--build` when you run. Another way to |
101 | | -easily rebuild and start your containers is with `make start-rebuild`. |
102 | | - |
103 | | -If you have only changed configuration values in .env, you can recreate your containers without |
104 | | -fully rebuilding them with `--force-recreate`. For example: |
105 | | - |
106 | | -```sh |
107 | | -docker compose --profile postgres down |
108 | | -docker compose --profile postgres up --force-recreate |
109 | | -``` |
110 | | - |
111 | | -To see what the environment of your containers is going to look like, run: |
112 | | - |
113 | | -```sh |
114 | | -docker compose --profile postgres convert |
115 | | -``` |
116 | | - |
117 | | -#### Using a local or remote (non-docker) database |
118 | | - |
119 | | -Omit the `--profile postgres` flag to use a local or remote database. You will need to set the `DATABASE_URL` environment variable in your `.env` file to point to your database. |
120 | | - |
121 | | -When using `make` commands, setting POSTGRES_DOCKER to `true` or `false` will determine whether to automatically include `--profile postgres` when it calls out to `docker compose`. |
122 | | - |
123 | | -#### Production Mode Shortcuts |
124 | | - |
125 | | -The commands in the Makefile can be prefaced with PROD. If so, the "dev overlay" configuration in `docker-compose.dev.yml` will be ignored. |
126 | | -Ports from services other than the HTTP proxy (80/443) will not be exposed. Containers will not mount local directories, watch for changes, |
127 | | -or rebuild themselves. In theory this should be one way to run Polis in a production environment. |
128 | | - |
129 | | -You need a `prod.env` file: |
130 | | - |
131 | | -`cp example.env prod.env` (and update accordingly). |
132 | | - |
133 | | -Then you can run things like: |
134 | | - |
135 | | -```sh |
136 | | -make PROD start |
137 | | - |
138 | | -make PROD start-rebuild |
139 | | -``` |
140 | | - |
141 | | -### Testing out your instance |
142 | | - |
143 | | -You can now test your setup by visiting `http://localhost:80/home`. |
144 | | - |
145 | | -Once the index page loads, you can create an account using the `/createuser` path. |
146 | | -You'll be logged in right away; email validation is not required. |
147 | | - |
148 | | -When you're done working, you can end the process using `Ctrl+C`, or typing `docker compose --profile postgres down` |
149 | | -if you are running in "detached mode". |
| 50 | +That should run docker compose with the development overlay (see below) and default configuration values. |
150 | 51 |
|
151 | | -### Updating the system |
| 52 | +Visit <http://localhost:80/createuser> 🚀 |
152 | 53 |
|
153 | | -If you want to update the system, you may need to handle the following: |
| 54 | +### Detailed Instructions |
154 | 55 |
|
155 | | -- [⬆️ Run database migrations](docs/migrations.md), if there are new such |
156 | | -- Update docker images by running with `--build` if there have been changes to the Dockerfiles |
157 | | - - consider using `--no-cache` if you'd like to rebuild from scratch, but note that this will take much longer |
| 56 | +* **Running Polis:** See [Running Polis](#running-polis) below for more details. |
| 57 | +* **Configuration:** See [`docs/configuration.md`](docs/configuration.md) for deployment configuration. |
| 58 | +* **Deployment:** See [`docs/deployment.md`](docs/deployment.md) for deployment bash commands. |
| 59 | +* **Contributing:** See [CONTRIBUTING.md](https://github.com/compdemocracy/polis/blob/edge/CONTRIBUTING.md) for how to contribute upstream polis main repository. |
| 60 | +* **Contributing:** See [our wiki](https://github.com/CivicTechTO/polis/wiki#if-you) for how to contribute to this fork. |
158 | 61 |
|
159 | | ---- |
| 62 | +## Running Polis |
160 | 63 |
|
161 | | -## 🚀 Production deployment |
| 64 | +Polis uses Docker and Docker Compose for easy setup. |
162 | 65 |
|
163 | | -While the commands above will get a functional Polis system up and running, additional steps must be taken to properly configure, secure and scale the system. |
164 | | -In particular |
| 66 | +### Prerequisites |
165 | 67 |
|
166 | | -- [⚙️ Configure the system](docs/configuration.md), esp: |
167 | | - - the domain name you'll be serving from |
168 | | - - enable and add API keys for 3rd party services (e.g. automatic comment translation, spam filtering, etc) |
169 | | -- [🔏 Set up SSL/HTTPS](docs/ssl.md), to keep the site secure |
170 | | -- [📈 Scale](docs/scaling.md) for large or many concurrent conversations |
| 68 | +* Docker and Docker Compose installed. [Instructions for avoiding `sudo` with Docker](https://docs.docker.com/engine/install/linux-postinstall/). |
171 | 69 |
|
172 | | -### Support |
| 70 | +### Basic Commands |
173 | 71 |
|
174 | | -We encourage you to take advantage of the public channels above for support setting up a deployment. |
175 | | -However, if you are deploying in a high impact context and need help, please [reach out to us][hello] |
| 72 | +* **Start (Development):** `make start` (Equivalent to `docker compose --profile postgres up`) |
| 73 | +* **Start (Rebuild):** `make start-rebuild` (Rebuilds Docker images) |
| 74 | +* **Start (Production - see docs/deployment.md for complete instructions):** `make PROD start` (Requires `prod.env`) |
| 75 | +* **Stop:** `make stop` (Equivalent to `docker compose --profile postgres down`) |
| 76 | +* **Help:** `make help` (Lists available commands) |
| 77 | +* **View Configuration:** `docker compose --profile postgres convert` |
| 78 | +* **Full Rebuild (Use with caution - wipes database):** `make start-FULL-REBUILD` |
176 | 79 |
|
177 | | ---- |
| 80 | +### Using a local or remote (non-docker) database |
| 81 | +See [Using a local or remote (non-docker) database](#using-a-local-or-remote-non-docker-database) below |
178 | 82 |
|
179 | | -## 💻 Development tooling |
| 83 | +### 💻 Development Mode |
180 | 84 |
|
181 | | -Once you've gotten [Polis running (as described above)](#-running-polis), you can enable developer conveniences by running |
| 85 | +For development, use the following command to enable live code reloading, debugging, and other conveniences: |
182 | 86 |
|
183 | 87 | ```bash |
184 | | -docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile postgres up |
| 88 | +docker compose -f docker-compose.yml -f docker-compose.dev.yml --profile postgres up --build |
185 | 89 | ``` |
186 | 90 |
|
187 | | -(run with `--build` if this is your first time running, or if you need to rebuild containers) |
188 | | - |
189 | | -This enables: |
190 | | - |
| 91 | +**This enables:** |
191 | 92 | - Live code reloading and static type checking of the server code |
192 | 93 | - A nREPL connection port open for connecting to the running math process |
193 | 94 | - Ports open for connecting directly to the database container |
194 | | -- Live code reloading for the client repos (in process) |
195 | | -- etc. |
196 | | - |
197 | | -This command takes advantage of the `docker-compose.dev.yml` _overlay_ file, which layers the developer conveniences describe above into the base system, as described in the `docker-compose.yml` file. |
198 | | -You can specify these `-f docker-compose.yml -f docker-compose.dev.yml` arguments for any `docker` command which you need to take advantage of these features (not just `docker compose --profile postgres up`). |
199 | | - |
200 | | -You can create your own `docker-compose.x.yml` file as an overlay and add or modify any values you need to differ |
201 | | -from the defaults found in the `docker-compose.yml` file and pass it as the second argument to the `docker compose -f` command above. |
202 | | - |
203 | | -### Testing |
204 | | - |
205 | | -We use Cypress for automated, end-to-end browser testing for PRs on GitHub (see badge above). |
206 | | -Please see [`e2e/README.md`](/e2e/README.md) for more information on running these tests locally. |
207 | | - |
208 | | -### Miscellaneous & troubleshooting |
209 | | - |
210 | | -#### Docker Problems |
211 | 95 |
|
212 | | -A lot of issues might be resolved by killing all docker containers and/or restarting docker entirely. If that doesn't |
213 | | -work, this will wipe all of your polis containers and volumes (**INCLUDING THE DATABASE VOLUME, so don't use this in prod!**) and completely rebuild them: |
| 96 | +**About docker compose overlay file:** |
| 97 | +* `docker-compose.dev.yml` in above command is an _overlay_ file, which layers the developer conveniences describe above into the base system, as described in the `docker-compose.yml` file. |
| 98 | +* You can create your own `docker-compose.x.yml` file as an overlay and add or modify any values you need to differ from the defaults found in the `docker-compose.yml` file and pass it as the second argument to the `docker compose -f` command above. |
| 99 | +* You can specify these `-f docker-compose.yml -f docker-compose.dev.yml` arguments for any `docker` command which you need to take advantage of these features (not just `docker compose --profile postgres up`). |
214 | 100 |
|
215 | | -`make start-FULL-REBUILD` |
| 101 | +## Using a local or remote (non-docker) database |
216 | 102 |
|
217 | | -see also `make help` for additional commands that might be useful. |
218 | | - |
219 | | -#### Git Configuration |
220 | | - |
221 | | -Due to past file re-organizations, you may find the following git configuration helpful for looking at history: |
222 | | - |
223 | | -```sh |
224 | | -git config --local include.path ../.gitconfig |
225 | | -``` |
226 | | - |
227 | | -#### Running as a background process |
| 103 | +Omit the `--profile postgres` flag to use a local or remote database. You will need to set the `DATABASE_URL` environment variable in your `.env` file to point to your database. |
228 | 104 |
|
229 | | -If you would like to run docker compose as a background process, run the `up` commands with the `--detach` flag, and use `docker compose --profile postgres down` to stop. |
| 105 | +When using `make` commands, setting POSTGRES_DOCKER to `true` or `false` will determine whether to automatically include `--profile postgres` when it calls out to `docker compose`. |
230 | 106 |
|
231 | | -#### Using Docker Machine as your development environment |
232 | 107 |
|
233 | | -If your development machine is having trouble handling all of the docker containers, look into [using Docker Machine](/docs/docker-machine.md). |
| 108 | +## Testing |
234 | 109 |
|
235 | | -#### Resolving problems with npm not finding libraries |
| 110 | +* **End-to-End (E2E) Tests:** See [`e2e/README.md`](e2e/README.md) for instructions on running automated browser tests. |
236 | 111 |
|
237 | | -Sometimes npm/docker get in a weird state, especially with native libs, and fail to recover gracefully. |
238 | | -You may get a message like `Error: Cannot find module .... bcrypt`. |
239 | 112 |
|
240 | | -If this happens to you, try |
241 | | -[following the instructions here.](https://github.com/compdemocracy/polis/issues/1391) |
| 113 | +## Troubleshooting |
242 | 114 |
|
243 | | -#### Issues with Apple Silicon (M1 & M2) chips |
| 115 | +* **Docker Issues:** Try restarting Docker, killing all containers, or using `make start-FULL-REBUILD` (WARNING: This wipes the database). |
| 116 | +* **NPM Issues:** See [this issue](https://github.com/compdemocracy/polis/issues/1391) for potential solutions. |
| 117 | +* **Apple Silicon (M1/M2) Issues:** You may need to use a [Rosetta terminal](https://support.apple.com/en-us/HT211861) for some dependencies. |
244 | 118 |
|
245 | | -You may find it necessary to install some dependencies, namely nodejs and postgres stuff, in a [Rosetta terminal](https://support.apple.com/en-us/HT211861). Create an issue or reach out if you are having strange build issues on Apple computers. |
246 | 119 |
|
247 | | -## ©️ License |
| 120 | +## License |
248 | 121 |
|
249 | 122 | [AGPLv3 with additional permission under section 7](/LICENSE) |
0 commit comments