-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: doc/template updates for initial setup
* Adds a version of the same `pull_configs.sh` script added to Screens earlier. This replaces a couple "ask another engineer for this file" setup steps, and removes the requirement to have AWS credentials set up in environment variables for `fetch_places_and_screens.exs`. * Provides (what I hope are) reasonable default values for URLs and other non-sensitive items in `.envrc.template`. This cuts down the values that must be filled in as part of setup to just a V3 API key. * Remove the root `package.json` that "proxied" some `npm` commands to the one in `assets`. It doesn't appear this was widely used, since using it generates a `package-lock.json` that was never committed.
- Loading branch information
1 parent
7e7f207
commit 423027f
Showing
4 changed files
with
89 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,49 @@ | ||
# Screenplay | ||
|
||
This tool enables PIOs to upload urgent messages to the Outfront signs in and outside stations. | ||
Enables OIOs to view and manage screens that provide transit info to riders. | ||
|
||
## Development | ||
|
||
To start your Phoenix server: | ||
## Setup | ||
|
||
- Set required env variables with | ||
- `export SECRET_KEY_BASE=`. You can use the value in `config.exs`. | ||
- `export GUARDIAN_SECRET_KEY=test_auth_secret` | ||
- URLs for other MBTA APIs that Screenplay communicates with. **Make sure to use the same environment for all!** | ||
- `export API_V3_URL="https://api-v3.mbta.com"` (or another environment's URL if you want to fetch data from there instead) | ||
- `export SCREENS_URL="https://screens.mbta.com"` (or another environment's URL if you want to fetch data from there instead) | ||
- Add a `places_and_screens.json` file to the `priv/config` directory. You can generate this file by running `API_V3_KEY=<your_key_here> mix run scripts/fetch_places_and_screens.exs --environment dev`. | ||
- Add a `screen_locations.json` file to the `priv/config` directory. You can either ask an engineer for a copy of the file, or enter an empty array as its contents (`[]`). The file just needs to exist and contain an array of 0 or more `{"id": "<screen ID>", "location": "<location description>"}` objects. | ||
- Add a `place_descriptions.json` file to the `priv/config` directory. You can either ask an engineer for a copy of the file, or enter an empty array as its contents (`[]`). The file just needs to exist and contain an array of 0 or more `{"id": "<place ID>", "description": "<place description>"}` objects. | ||
- Install dependencies with `mix deps.get` | ||
- Install Node.js dependencies by running `npm run install` | ||
- Start Phoenix endpoint with `API_V3_KEY=<your-key-here> mix phx.server` | ||
#### Install tools | ||
|
||
If you want to develop on Screenplay with a local version of the Screens app, just spin up Screens (which will be at http://localhost:4000) and change the dev baseUrl in ScreenDetail.tsx to use that port 4000 url. | ||
1. Install [`asdf`](https://github.com/asdf-vm/asdf) | ||
1. Install language build dependencies: `brew install coreutils` | ||
1. `asdf plugin-add ...` for each tool listed in `.tool-versions` | ||
1. `asdf install` | ||
|
||
Now you can visit [`localhost:4444`](http://localhost:4444) from your browser. | ||
#### Set up environment | ||
|
||
You may want to add `export API_V3_KEY=<your-key-here>` to your shell config so that you don't have to specify it each time you run `mix phx.server`. | ||
1. Install [`direnv`](https://direnv.net/) | ||
1. `cp .envrc.template .envrc` | ||
1. Fill in `API_V3_KEY` with a [V3 API key](https://api-v3.mbta.com/) | ||
1. `direnv allow` | ||
|
||
Note the various `_URL` values in `.envrc`, which default to the production | ||
environments of the relevant apps — change these to e.g. point Screenplay to | ||
your own local instances. | ||
|
||
#### Copy configuration | ||
|
||
1. Install the `aws` CLI and configure with your AWS credentials | ||
- To verify everything works, try: `aws s3 ls mbta-ctd-config` | ||
1. Run `scripts/pull_configs.sh prod` | ||
|
||
To copy config files from a different Screenplay environment, replace `prod` in | ||
the command above. | ||
|
||
#### Start the server | ||
|
||
1. `mix deps.get` | ||
1. `npm install --prefix assets` | ||
1. `mix phx.server` | ||
1. Visit <http://localhost:4444> | ||
|
||
#### Optional: AWS credentials | ||
|
||
In deployed environments, the app uses S3 for its configuration. If you ever | ||
want to replicate this behavior locally, you'll need to provide the environment | ||
variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. For security reasons | ||
these should only be [stored in 1Password][1] and not directly in your `.envrc`. | ||
|
||
[1]: https://www.notion.so/mbta-downtown-crossing/Storing-Access-Keys-Securely-in-1Password-b89310bc67784722a5a218500f34443d?pm=c |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
# Copies live configuration from S3 to the local paths expected by `LocalFetch` | ||
# modules. | ||
|
||
set -eu | ||
|
||
if [ $# -eq 0 ]; then | ||
echo "Usage: $0 <screenplay-env-name>" >&2 | ||
exit 1 | ||
fi | ||
|
||
case $1 in | ||
prod | dev | dev-green) true;; | ||
* ) | ||
echo "Environment should be: prod | dev | dev-green" >&2 | ||
exit 2 | ||
;; | ||
esac | ||
|
||
maybe_cp() { | ||
if [ -e "$2" ]; then | ||
printf '%s' "Overwrite $2? " | ||
read -r answer | ||
case $answer in | ||
[Yy]* ) aws s3 cp "$1" "$2";; | ||
* ) echo "Skipped.";; | ||
esac | ||
fi | ||
} | ||
|
||
maybe_cp s3://mbta-ctd-config/screenplay/"$1".json priv/alerts.json | ||
maybe_cp s3://mbta-ctd-config/screenplay/"$1"/place_descriptions.json priv/config/place_descriptions.json | ||
maybe_cp s3://mbta-ctd-config/screenplay/"$1"/places_and_screens.json priv/config/places_and_screens.json | ||
maybe_cp s3://mbta-ctd-config/screenplay/"$1"/screen_locations.json priv/config/screen_locations.json |