Skip to content

Commit bc61ee4

Browse files
authored
Merge pull request #6522 from NHSDigital/procfile-dev-no-redis
Update and document local database setup
2 parents e68caee + e7603f0 commit bc61ee4

5 files changed

Lines changed: 42 additions & 70 deletions

File tree

Procfile.dev

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ web: bin/falcon serve -b http://localhost:4000
22
sidekiq: bin/sidekiq
33
css: yarn build:css --watch
44
js: yarn build --watch
5-
redis: redis-server

Procfile.e2e

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
web: RAILS_ENV=end_to_end bin/falcon serve -b http://localhost:4100
1+
web: RAILS_ENV=end_to_end bin/falcon serve -b http://localhost:4100
22
sidekiq: RAILS_ENV=end_to_end bin/sidekiq
3-
css: yarn build:css --watch
4-
js: yarn build --watch=forever
5-
redis: redis-server --port 6380
3+
css: yarn build:css --watch
4+
js: yarn build --watch=forever

README.md

Lines changed: 38 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ This is a service used within the NHS for managing and recording school-aged vac
66

77
| Name | URL | Purpose | Care Identity login | Code | Deployment | `RAILS_ENV` |
88
| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ---------------------------- | ------------------- | ------------------------------ | ---------- | ------------------------------------------------- |
9-
| [Heroku](https://github.com/nhsuk/manage-vaccinations-in-schools/deployments/heroku) | mavis-pr-xxxx.herokuapp.com | PR review apps || pull request branch | automated | [`staging`](config/environments/staging.rb) |
109
| [Test](https://github.com/nhsuk/manage-vaccinations-in-schools/deployments/test) | [test.mavistesting.com](https://test.mavistesting.com) | Internal testing (manual) || `main` branch (latest) | automated | [`staging`](config/environments/staging.rb) |
1110
| [QA](https://github.com/nhsuk/manage-vaccinations-in-schools/deployments/qa) | [qa.mavistesting.com](https://qa.mavistesting.com) | Internal testing (automated) || `main` branch (latest) | automated | [`staging`](config/environments/staging.rb) |
1211
| [Preview](https://github.com/nhsuk/manage-vaccinations-in-schools/deployments/Preview) | [preview.mavistesting.com](https://preview.mavistesting.com) | External testing || `release` or release candidate | manual | [`staging`](config/environments/staging.rb) |
1312
| [Training](https://github.com/nhsuk/manage-vaccinations-in-schools/deployments/training) | [training.manage-vaccinations-in-schools.nhs.uk](https://training.manage-vaccinations-in-schools.nhs.uk) | External training || `release` branch | manual | [`staging`](config/environments/staging.rb) |
1413
| [Production](https://github.com/nhsuk/manage-vaccinations-in-schools/deployments/production) | [www.manage-vaccinations-in-schools.nhs.uk](https://www.manage-vaccinations-in-schools.nhs.uk) | Live service || `release` branch | manual | [`production`](config/environments/production.rb) |
1514

16-
## Documentation
15+
## API Documentation
1716

18-
We have two Rdoc versions:
17+
We have two RDoc versions:
1918

2019
1. [next](https://nhsuk.github.io/manage-vaccinations-in-schools/rdoc/next) - useful for dev work (based off the `next` branch).
2120
2. [release](https://nhsuk.github.io/manage-vaccinations-in-schools/rdoc/release) - useful for ops to debug live issues (based off the `release` branch).
@@ -47,9 +46,7 @@ We use `rladr` to generate the boilerplate for new records:
4746
bin/bundle exec rladr new title
4847
```
4948

50-
### Development toolchain
51-
52-
#### Mise
49+
### Installing dependencies
5350

5451
This project uses `mise`. Use the following to set up (replace `brew` and
5552
package names depending on your platform):
@@ -84,20 +81,46 @@ Then to install the required tools (or update, following a change to
8481
mise install
8582
```
8683

87-
After installing Postgres via `mise`, run the database in the background, and
88-
connect to it to create a user:
84+
### Background services
85+
86+
For the application to start successfully, PostgreSQL and Redis/Valkey must be
87+
running.
88+
89+
#### PostgreSQL
90+
91+
If using `brew`, the simplest option is to run `brew services start postgresql`.
92+
93+
Alternatively, you can run the server manually:
8994

9095
```shell
9196
pg_ctl start
9297
psql -U postgres -c "CREATE USER $(whoami); ALTER USER $(whoami) WITH SUPERUSER;"
9398
```
9499

95-
### Local development
100+
#### Redis/Valkey
96101

97-
To run the project locally:
102+
If using `brew`, the simplest option is to run `brew services start redis`.
103+
104+
Alternatively, you can run the server manually:
98105

99106
```shell
100-
bin/setup
107+
redis-server
108+
```
109+
110+
### Running locally
111+
112+
When running for the first time, `bin/setup` will automatically install Ruby
113+
dependencies and set up the database.
114+
115+
This application also comes with a `Procfile.dev` for use with `foreman` in
116+
development environments. Use the script `bin/dev` to run it:
117+
118+
```shell
119+
$ bin/dev
120+
13:07:31 web.1 | started with pid 73965
121+
13:07:31 css.1 | started with pid 73966
122+
13:07:31 js.1 | started with pid 73967
123+
...
101124
```
102125

103126
### Branching strategy
@@ -141,39 +164,7 @@ You'll also need to configure your editor's `solargraph` plugin to
141164
+ "solargraph.useBundler": true,
142165
```
143166

144-
### PostgreSQL
145-
146-
The script `bin/db` is included to start up PostgreSQL for setups that don't use
147-
system-started services. Note that this is meant to be a handy script to manage
148-
PostgreSQL, not run a console like `rails db` does.
149-
150-
```shell
151-
$ bin/db
152-
pg_ctl: no server running
153-
$ bin/db start
154-
waiting for server to start.... done
155-
server started
156-
$ bin/db
157-
pg_ctl: server is running (PID: 79113)
158-
```
159-
160-
This script attempts to be installation agnostic by relying on `pg_config` to
161-
determine postgres's installation directory and setting up logging accordingly.
162-
163-
### Development server
164-
165-
This application comes with a `Procfile.dev` for use with `foreman` in
166-
development environments. Use the script `bin/dev` to run it:
167-
168-
```shell
169-
$ bin/dev
170-
13:07:31 web.1 | started with pid 73965
171-
13:07:31 css.1 | started with pid 73966
172-
13:07:31 js.1 | started with pid 73967
173-
...
174-
```
175-
176-
#### Debugging with `binding.pry`
167+
### Debugging with `binding.pry`
177168

178169
TTY echo can get mangled when using `binding.pry` in `bin/dev`. To work around
179170
this, you can run `rails s` directly if you're not working with any JS or CSS
@@ -235,7 +226,7 @@ RAILS_ENV=end_to_end bin/mavis gias import --input-file=spec/fixtures/dfe-school
235226

236227
You can generate an example programme by seeding the database with `rails db:seed:replant`.
237228

238-
#### Adding a test user
229+
### Adding a test user
239230

240231
You can add a new user to an environment using the `users:create` [rake task](docs/rake-tasks.md#userscreateemailpasswordgiven_namefamily_nameteam_ods_code):
241232

@@ -260,11 +251,6 @@ rails users:create\[user@example.com,password123,John,Doe,R1L\]
260251

261252
The previews are defined in `spec/components/previews`.
262253

263-
### Deploying
264-
265-
This app can be deployed to AWS using the relevant [github workflow](.github/workflows/deploy.yml). The infrastructure
266-
configuration is located in [its own repository](https://github.com/NHSDigital/manage-vaccinations-in-schools-infrastructure)
267-
268254
### Notify
269255

270256
When developing locally, emails are sent using the `:file` delivery method, and
@@ -331,11 +317,11 @@ The `private_key` will automatically be used to generate a JWK on the
331317
`/oidc/jwks` endpoint, which is used by CIS2 to validate the JWT we use to
332318
request the access token from CIS2.
333319

334-
### Reporting
320+
## Reporting
335321

336322
See [docs/reporting.md](docs/reporting.md).
337323

338-
#### Key Rotation
324+
### Key Rotation
339325

340326
Keys should be rotated regularly. When a new key is introduced it's JWK will
341327
automatically be added to the JWKS generated for `/oidc/jwks`, but the old

bin/db

Lines changed: 0 additions & 11 deletions
This file was deleted.

bin/e2e

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ RAILS_ENV="end_to_end"
66
RAILS_PORT="4100"
77
HEALTH_CHECK_URL="http://localhost:${RAILS_PORT}/up"
88
MAVIS_TEST_REPO="${MAVIS_TEST_REPO:-"../manage-vaccinations-in-schools-testing"}"
9-
E2E_REDIS_URL="redis://localhost:6380/0"
109
PYTEST_ARGS=("-m" "not accessibility and not reporting and not imms_api and not pds_api")
1110

1211
# Argument handling
@@ -145,7 +144,7 @@ else
145144
fi
146145

147146
echo "[e2e] Starting rails server with foreman. Logs will be written to /tmp/e2e-foreman.log"
148-
RAILS_ENV="$RAILS_ENV" SIDEKIQ_REDIS_URL="$E2E_REDIS_URL" "${START_FOREMAN[@]}" >/tmp/e2e-foreman.log 2>&1 &
147+
RAILS_ENV="$RAILS_ENV" "${START_FOREMAN[@]}" >/tmp/e2e-foreman.log 2>&1 &
149148
E2E_PGID=$!
150149

151150

0 commit comments

Comments
 (0)