Skip to content

Commit 38de057

Browse files
authored
Merge pull request #297 from integer32llc/dotenv
Add dotenv support
2 parents 3c1b118 + 56effd1 commit 38de057

File tree

5 files changed

+48
-12
lines changed

5 files changed

+48
-12
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,19 @@ basic HTML/CSS/JS changes, directly open in your browser the built
9696
`ui/frontend/build/index.html`.
9797

9898
### Build and run the server
99+
100+
Configure your `.env` file as described in the [ui README](./ui/README.md).
101+
99102
```
100103
cd ui
101-
RUST_LOG=ui=debug \
102-
PLAYGROUND_UI_ROOT=$PWD/frontend/build/ \
103-
PLAYGROUND_GITHUB_TOKEN=YOUR_TOKEN \
104104
cargo run
105105
```
106106

107-
### Build the containers
107+
### Build or download the containers
108108
```
109109
cd compiler
110-
./build.sh
110+
./build.sh # If you want to test changes to the containers
111+
./fetch.sh # If you just want the current playground
111112
```
112113

113114
## Deployment

ui/Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ hyper = "0.11.21"
3030
hyper-tls = "0.1.2"
3131
router = "0.6.0"
3232
openssl-probe = "0.1.2"
33+
dotenv = "0.11.0"
3334

3435
[dependencies.playground-middleware]
3536
git = "https://github.com/integer32llc/playground-middleware"

ui/README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
## Configuration
22

3-
| Key | Required | Default Value | Description |
4-
| ------------------------|-----------|-----------------|-------------------------------------------------------------------------|
5-
| `PLAYGROUND_UI_ROOT` | **Yes** | | The path to the HTML, CSS, and Javascript files |
6-
| `PLAYGROUND_UI_ADDRESS` | No | 127.0.0.1 | The address to listen on |
7-
| `PLAYGROUND_UI_PORT` | No | 5000 | The port to listen on |
8-
| `PLAYGROUND_LOG_FILE` | No | access-log.csv | The file to record accesses |
9-
| `TMPDIR` | No | system-provided | Where compilation artifacts will be saved. Must be accessible to Docker |
3+
When developing, you can place these in a [`.env`][dotenv] file on
4+
disk in this directory.
5+
6+
In production, these should be set according to your deployment method
7+
of choice.
8+
9+
| Key | Required | Default Value | Description |
10+
| --------------------------|----------|-----------------|-------------------------------------------------------------------------|
11+
| `PLAYGROUND_UI_ROOT` | **Yes** | | The path to the HTML, CSS, and Javascript files |
12+
| `PLAYGROUND_GITHUB_TOKEN` | **Yes** | | The [GitHub API token][gist] to read and write Gists |
13+
| `PLAYGROUND_UI_ADDRESS` | No | 127.0.0.1 | The address to listen on |
14+
| `PLAYGROUND_UI_PORT` | No | 5000 | The port to listen on |
15+
| `PLAYGROUND_LOG_FILE` | No | access-log.csv | The file to record accesses |
16+
| `TMPDIR` | No | system-provided | Where compilation artifacts will be saved. Must be accessible to Docker |
17+
18+
[dotenv]: https://crates.io/crates/dotenv
19+
[gist]: https://developer.github.com/v3/gists/#authentication

ui/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#[macro_use]
44
extern crate log;
55
extern crate env_logger;
6+
extern crate dotenv;
67
extern crate iron;
78
extern crate mount;
89
extern crate router;
@@ -66,6 +67,7 @@ const ONE_YEAR_IN_SECONDS: u64 = 60 * 60 * 24 * 365;
6667
const SANDBOX_CACHE_TIME_TO_LIVE_IN_SECONDS: u64 = ONE_HOUR_IN_SECONDS as u64;
6768

6869
fn main() {
70+
dotenv::dotenv().unwrap();
6971
openssl_probe::init_ssl_cert_env_vars();
7072
env_logger::init();
7173

0 commit comments

Comments
 (0)