Skip to content

Commit 5f2d573

Browse files
committed
Docs updates, separates nix and non-nix install processes, edits to simplify for both. Update to add index for coherency for devs and reduce some redundancy. (#1379)
1 parent cec1ff9 commit 5f2d573

8 files changed

+131
-190
lines changed

.envrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ if [ -f ".env" ]; then
33
dotenv
44
fi
55
if [ -f "$HOME/.config/nix/nix.conf" ]; then
6-
echo "Entering nix shell environment."
6+
echo "Loading nix shell environment."
77
use flake
88
fi

README.md

Lines changed: 48 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A Django based website that will power a new Boost website. See the [documentati
66

77
Links:
88

9-
- https://www.stage.boost.cppalliance.org/ - staging
9+
- https://stage.boost.org/ - staging
1010
- https://www.boost.org/ - production
1111

1212
---
@@ -15,54 +15,65 @@ Links:
1515

1616
This project will use Python 3.11, Docker, and Docker Compose.
1717

18-
Instructions to install those packages are included in [development_setup_notes.md](docs/development_setup_notes.md).
19-
20-
**NOTE**: All of these various `docker compose` commands, along with other helpful
21-
developer utility commands, are codified in our `justfile` and can be ran with
22-
less typing.
23-
24-
You will need to install `just`, by [following the documentation](https://just.systems/man/en/)
25-
26-
**Environment Variables**: Copy file `env.template` to `.env` and adjust values to match your local environment. See [Environment Variables](docs/env_vars.md) for more information.
27-
28-
```shell
29-
$ cp env.template .env
30-
```
31-
32-
**NOTE**: Double check that the exposed port assigned to the PostgreSQL
33-
container does not clash with a database or other server you have running
34-
locally.
35-
36-
Then run:
18+
There are two options for development setups, nix and native. The native setup doesn't require nix to be installed. The nix-based setup works in a similar way to a python venv, with everything encapsulated for the project. Note: it is not a vm. It handles installation of all of the application and development environment's dependencies automatically:
19+
20+
- The python version relevant to the project
21+
- awscli
22+
- gdk
23+
- just
24+
- opentofu
25+
- nodejs
26+
- yarn
27+
- asciidoctor
28+
- asciidoctor-boost gem
29+
- pre-commit
30+
- black
31+
- isort
32+
- pip-tools
33+
34+
35+
1. Development System setup
36+
1. Basic Setup Options:
37+
1. [Nix-based](docs/development_setup_notes_nix.md)
38+
1. [Native](docs/development_setup_notes_native.md)
39+
1. [Initial Data Setup](docs/first_time_data_import.md)
40+
1. [Allauth Social Login Setup](docs/allauth_setup.md)
41+
1. System Concepts
42+
1. [GitHub Data Syncing](docs/syncing_data_with_github.md)
43+
1. [Rendered Content Caching](docs/caching_rendered_content.md)
44+
1. [Static Content from S3](docs/static_content.md)
45+
1. ['manage' Commands](docs/commands.md)
46+
1. [API](docs/api.md)
47+
1. [RSS Feeds](docs/rss_feeds.md)
48+
1. [Env Vars](docs/env_vars.md)
49+
1. [Calendar](docs/calendar.md)
50+
1. [News](docs/news.md)
51+
1. Instructional
52+
1. [Dependency Updates](docs/dependencies.md)
53+
1. [Release Reports](docs/release_reports.md)
54+
1. [User Management](docs/user_management.md)
55+
1. [Non-Dev Server Allauth Setup](docs/non-dev-server-allauth-setup.md)
56+
1. [Admin Features](docs/admin.md)
57+
1. [Mailing List Setup](docs/mailing_list.md)
58+
59+
After going through the "Development System setup" steps above to create the Docker image, install dependencies, and start the services in `docker-compose.yml`, run:
3760

3861
```shell
3962
# start our services (and build them if necessary)
4063
$ docker compose up
4164

4265
# to create database migrations
43-
$ docker compose run --rm web python manage.py makemigrations
66+
$ just makemigrations
4467

4568
# to run database migrations
46-
$ docker compose run --rm web python manage.py migrate
69+
$ just migrate
4770

4871
# to create a superuser
49-
$ docker compose run --rm web python manage.py createsuperuser
72+
$ just manage createsuperuser
5073
```
5174

52-
This will create the Docker image, install dependencies, start the services
53-
defined in `docker-compose.yml`, and start the webserver.
54-
5575
styles.css is still missing in a local docker-compose environment. Steps to add it:
5676

57-
```
58-
# One-time setup
59-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
60-
. ~/.bashrc
61-
nvm install 20
62-
nvm use 20
63-
npm install -g yarn
64-
```
65-
6677
```
6778
# Each time - rebuild styles.css
6879
yarn
@@ -90,13 +101,13 @@ $ docker compose down
90101
To run the tests, execute:
91102

92103
```shell
93-
$ docker compose run --rm web pytest
104+
$ just test
94105
```
95106

96107
or run:
97108

98109
```shell
99-
$ just test
110+
$ docker compose run --rm web pytest
100111
```
101112

102113
## Yarn and Tailwind
@@ -125,22 +136,6 @@ currently generated by `docker compose build` and is included in the Docker imag
125136

126137
---
127138

128-
## Generating Local Data
129-
130-
To **add real Boost libraries and sync all the data from GitHub and S3**, set appropriate values in your new .env file according to [Environment Variables](docs/env_vars.md) for `GITHUB_TOKEN`, `STATIC_CONTENT_AWS_ACCESS_KEY_ID`, `STATIC_CONTENT_AWS_SECRET_ACCESS_KEY`, `STATIC_CONTENT_BUCKET_NAME`, `STATIC_CONTENT_REGION`, `STATIC_CONTENT_AWS_S3_ENDPOINT_URL` then run:
131-
132-
```bash
133-
docker compose run --rm web python manage.py update_libraries --local
134-
```
135-
136-
Those values can be gotten from another developer in the `#boost-website` Slack channel.
137-
138-
The `--local` flag speeds up the command a lot by excluding the retrieval of data you generally don't need. For more information, see `update_libraries` in [Management Commands](docs/commands.md).
139-
140-
Then as a superuser log into the admin interface, go to "Versions" and click on the "import new releases" button in the top right.
141-
142-
---
143-
144139
## Setting up Mailman/Hyperkitty locally
145140
``shell
146141
sudo apt-get install sassc
@@ -190,17 +185,6 @@ We use [pre-commit hooks](https://pre-commit.com/) to check code for style, synt
190185
| [Ruff](https://github.com/charliermarsh/ruff) | Wrapper around `flake8` and `isort`, among other linters |
191186
| [Djhtml](https://github.com/rtts/djhtml) | Auto-formats Django templates |
192187

193-
### Setup and Usage
194-
195-
| Description | Command |
196-
| ---- | ------- |
197-
| 1. Install the `pre-commit` package using `pip` | `pip install pre-commit` |
198-
| 2. Install our list of pre-commit hooks locally | `pre-commit install` |
199-
| 3. Run all hooks for changed files before commit | `pre-commit run` |
200-
| 4. Run specific hook before commit | `pre-commit run {hook}` |
201-
| 5. Run hooks for all files, even unchanged ones | `pre-commit run --all-files` |
202-
| 6. Commit without running pre-commit hooks | `git commit -m "Your commit message" --no-verify` |
203-
204188
Example commands for running specific hooks:
205189

206190
| Hook | Example |

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- [Boost Mailing List](./mailing_list.md) -Includes OAuth instructions
55
- [Caching and the `RenderedContent` model](./caching_rendered_content.md)
66
- [Dependency Management](./dependencies.md)
7-
- [Development Setup Notes](./development_setup_notes.md)
7+
- [Development Setup Notes](development_setup_notes_native.md)
88
- [Environment Variables](./env_vars.md)
99
- [Events Calendar](./calendar.md)
1010
- [Example Files](./examples/README.md) - Contains samples of `libraries.json`. `.gitmodules`, and other files that Boost data depends on

docs/allauth_setup.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
### Social Login with django-allauth
2+
3+
Follow these instructions to use the social logins through django-allauth on your local machine.
4+
5+
See https://testdriven.io/blog/django-social-auth/ for more information.
6+
7+
#### Github
8+
- Go to https://github.com/settings/applications/new and add a new OAuth application
9+
- Set `http://localhost:8000` as the Homepage URL
10+
- Set `http://localhost:8000/accounts/github/login/callback/` as the Callback URL
11+
- Click whether you want to enable the device flow
12+
- <img src="https://user-images.githubusercontent.com/2286304/252841283-9a846c68-46bb-4dac-8d1e-d35270c09f1b.png" alt="The GitHub screen that registers a new OAuth app" width="400">
13+
- On completion copy the Client ID and Client Secret to the `.env` file as values of `GITHUB_OAUTH_CLIENT_ID` and `GITHUB_OAUTH_CLIENT_SECRET`.
14+
- Run `direnv allow` and restart your docker containers.
15+
16+
Setup should be complete and you should be able to see an option to "Use Github" on the sign up page.
17+
18+
To test the flow including authorizing Github for the Boost account, log into your GitHub account settings and click **Applications** in the left menu. Find the "Boost" authorization and delete it. The next time you log into Boost with this GitHub account, you will have to re-authorize it.
19+
20+
<img src="https://user-images.githubusercontent.com/2286304/204642346-8b269aaf-4693-4351-9474-0a998b97689c.png" alt="The 'Authorized OAuth Apps' tab in your GitHub Applications" width="400">
21+
22+
This setup process is not something that can currently be automated through terraform because of a lack of relevant Github API endpoints to create Oauth credentials.
23+
24+
#### Google
25+
26+
More detailed instructions at:
27+
28+
https://docs.allauth.org/en/latest/socialaccount/providers/google.html
29+
30+
1. Update the `.env` file with values for:
31+
1. `TF_VAR_google_cloud_email` (the email address of your Google Cloud account)
32+
2. `TF_VAR_google_organization_domain` (usually the domain of your Google Cloud account, e.g. "boost.org" if you will be using a @boost.org email address)
33+
3. `TF_VAR_google_cloud_project_name` (optional, default: localboostdev) - needs to change if destroyed and a setup is needed within 30 days
34+
2. Run `just development-tofu-init` to initialize tofu.
35+
3. Run `just development-tofu-plan` to confirm the planned changes.
36+
4. Run `just development-tofu-apply` to apply the changes.
37+
5. Go to https://console.developers.google.com/
38+
1. Search for the newly created project, named "Boost Development" (ID: localboostdev by default).
39+
2. Type "credentials" in the search input at the top of the page.
40+
3. Select "Credentials" under "APIs & Services".
41+
1. Click "+ CREATE CREDENTIALS"
42+
2. Select "OAuth Client ID"
43+
3. Select Application Type: "Web application"
44+
4. Name: "Boost Development" (arbitrary)
45+
5. For "Authorized Javascript Origins" use:`http://localhost:8000`
46+
6. For "Authorized Redirect URIs" use:
47+
* `http://localhost:8000/accounts/google/login/callback/`
48+
* `http://localhost:8000/accounts/google/login/callback/?flowName=GeneralOAuthFlow`
49+
7. Save
50+
6. From the page that's displayed, update the `.env` file with values for the following:
51+
- `GOOGLE_OAUTH_CLIENT_ID` should be similar to "k235bn2b1l1(...)asdsk.apps.googleusercontent.com"
52+
- `GOOGLE_OAUTH_CLIENT_SECRET` should be similar to "LAJACO(...)KLAI612ANAD"
53+
54+
Point 5 above can not be automated through terraform because of a lack of relevant Google Cloud API endpoints to create Oauth credentials.
55+
56+
Setup should be complete and you should be able to see an option to "Use Google" on the sign up page.
57+
58+
#### Additional Notes on allauth login flows:
59+
**Working locally**: If you need to run through the login flows multiple times, create a superuser so you can log into the admin. Then, log into the admin and delete your "Social Account" from the admin. This will test a fresh connection to GitHub for your logged-in GitHub user.

docs/development_setup_notes.md renamed to docs/development_setup_notes_native.md

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -271,72 +271,24 @@ cd website-v2
271271
cp env.template .env
272272
```
273273

274-
Edit the .env, adding AWS keys.
275-
276-
Continue to the instructions in the top-level README.md file.
277-
278-
## Local Development
279-
280-
### Social Login with django-allauth
281-
282-
Follow these instructions to use the social logins through django-allauth on your local machine.
283-
284-
See https://testdriven.io/blog/django-social-auth/ for more information.
285-
286-
#### Github
287-
- Go to https://github.com/settings/applications/new and add a new OAuth application
288-
- Set `http://localhost:8000` as the Homepage URL
289-
- Set `http://localhost:8000/accounts/github/login/callback/` as the Callback URL
290-
- Click whether you want to enable the device flow
291-
- <img src="https://user-images.githubusercontent.com/2286304/252841283-9a846c68-46bb-4dac-8d1e-d35270c09f1b.png" alt="The GitHub screen that registers a new OAuth app" width="400">
292-
- On completion copy the Client ID and Client Secret to the `.env` file as values of `GITHUB_OAUTH_CLIENT_ID` and `GITHUB_OAUTH_CLIENT_SECRET`.
293-
- Run `direnv allow` and restart your docker containers.
274+
Edit the .env, adding AWS keys, and adjust values to match your local environment. See [Environment Variables](docs/env_vars.md) for more information.
294275

295-
Setup should be complete and you should be able to see an option to "Use Github" on the sign up page.
276+
**NOTE**: Double check that the exposed port assigned to the PostgreSQL
277+
container does not clash with a database or other server you have running
278+
locally.
296279

297-
To test the flow including authorizing Github for the Boost account, log into your GitHub account settings and click **Applications** in the left menu. Find the "Boost" authorization and delete it. The next time you log into Boost with this GitHub account, you will have to re-authorize it.
280+
### Pre-commit Hooks Setup
298281

299-
<img src="https://user-images.githubusercontent.com/2286304/204642346-8b269aaf-4693-4351-9474-0a998b97689c.png" alt="The 'Authorized OAuth Apps' tab in your GitHub Applications" width="400">
282+
| Description | Command |
283+
| ---- | ------- |
284+
| 1. Install the `pre-commit` package using `pip` | `pip install pre-commit` |
285+
| 2. Install our list of pre-commit hooks locally | `pre-commit install` |
286+
| 3. Run all hooks for changed files before commit | `pre-commit run` |
287+
| 4. Run specific hook before commit | `pre-commit run {hook}` |
288+
| 5. Run hooks for all files, even unchanged ones | `pre-commit run --all-files` |
289+
| 6. Commit without running pre-commit hooks | `git commit -m "Your commit message" --no-verify` |
300290

301-
This setup process is not something that can currently be automated through terraform because of a lack of relevant Github API endpoints to create Oauth credentials.
302-
303-
#### Google
304-
305-
More detailed instructions at:
306-
307-
https://docs.allauth.org/en/latest/socialaccount/providers/google.html
308-
309-
1. Update the `.env` file with values for:
310-
1. `TF_VAR_google_cloud_email` (the email address of your Google Cloud account)
311-
2. `TF_VAR_google_organization_domain` (usually the domain of your Google Cloud account, e.g. "boost.org" if you will be using an @boost.org email address)
312-
3. `TF_VAR_google_cloud_project_name` (optional, default: localboostdev) - needs to change if destroyed and a setup is needed within 30 days
313-
2. Run `just development-tofu-init` to initialize tofu.
314-
3. Run `just development-tofu-plan` to confirm the planned changes.
315-
4. Run `just development-tofu-apply` to apply the changes.
316-
5. Go to https://console.developers.google.com/
317-
1. Search for the newly created project, named "Boost Development" (ID: localboostdev by default).
318-
2. Type "credentials" in the search input at the top of the page.
319-
3. Select "Credentials" under "APIs & Services".
320-
1. Click "+ CREATE CREDENTIALS"
321-
2. Select "OAuth Client ID"
322-
3. Select Application Type: "Web application"
323-
4. Name: "Boost Development" (arbitrary)
324-
5. For "Authorized Javascript Origins" use:`http://localhost:8000`
325-
6. For "Authorized Redirect URIs" use:
326-
* `http://localhost:8000/accounts/google/login/callback/`
327-
* `http://localhost:8000/accounts/google/login/callback/?flowName=GeneralOAuthFlow`
328-
7. Save
329-
6. From the page that's displayed, update the `.env` file with values for the following:
330-
- `GOOGLE_OAUTH_CLIENT_ID` should be similar to "k235bn2b1l1(...)asdsk.apps.googleusercontent.com"
331-
- `GOOGLE_OAUTH_CLIENT_SECRET` should be similar to "LAJACO(...)KLAI612ANAD"
332-
7. Run `direnv allow` and restart your docker containers.
333-
334-
Point 5 above can not be automated through terraform because of a lack of relevant Google Cloud API endpoints to create Oauth credentials.
335-
336-
Setup should be complete and you should be able to see an option to "Use Google" on the sign up page.
337-
338-
#### Additional Notes:
339-
**Working locally**: If you need to run through the login flows multiple times, create a superuser so you can log into the admin. Then, log into the admin and delete your "Social Account" from the admin. This will test a fresh connection to GitHub for your logged-in GitHub user.
291+
Continue to the instructions in the top-level README.md file.
340292

341293
### Debugging
342294
For local development there is Django Debug Toolbar, and the option to set a debugger.

0 commit comments

Comments
 (0)