Skip to content

Commit c339a70

Browse files
authored
Merge branch 'master' into add-region-to-circleci-config
2 parents 940c198 + 344d3fa commit c339a70

File tree

4 files changed

+142
-58
lines changed

4 files changed

+142
-58
lines changed

.circleci/config.yml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ jobs:
119119
docker:
120120
- image: *build-image
121121
working_directory: *workspace
122+
parameters:
123+
config:
124+
description: |
125+
The config file you want to build the app using.
126+
E.g. 'development' would load configurations from 'config/development.json'
127+
type: enum
128+
enum: ["development", "staging", "production"]
129+
default: production
122130
steps: # steps that comprise the `build` job
123131
- attach_workspace:
124132
at: *workspace
@@ -131,12 +139,13 @@ jobs:
131139
name: Build static side
132140
command: |
133141
yarn
134-
yarn build
142+
REACT_APP_CONFIG=<< parameters.config >> yarn build
143+
mv build build_<< parameters.config >>
135144
136145
- persist_to_workspace:
137146
root: /home/circleci/project
138147
paths:
139-
- build
148+
- build_<< parameters.config >>
140149

141150
- save_cache: # Store cache in the /go/pkg directory
142151
key: v1-pkg-cache-{{ checksum "yarn.lock" }}
@@ -150,6 +159,13 @@ jobs:
150159
docker:
151160
- image: cimg/python:3.6
152161
parameters:
162+
config:
163+
description: |
164+
The config file you want to build the app using.
165+
E.g. 'development' would load configurations from 'config/development.json'
166+
type: enum
167+
enum: ["development", "staging", "production"]
168+
default: production
153169
bucket:
154170
description: The S3 Bucket to sync files to.
155171
type: string
@@ -164,7 +180,7 @@ jobs:
164180
- run: # Required by aws-cli
165181
command: echo 'export AWS_REGION=<< parameters.region >>' >> $BASH_ENV
166182
- aws-s3/sync:
167-
from: build
183+
from: build_<< parameters.config >>
168184
overwrite: true
169185
to: 's3://<< parameters.bucket >>'
170186

@@ -180,13 +196,22 @@ workflows:
180196
- checkout_code
181197

182198
- build:
199+
name: build_staging
200+
config: staging
183201
requires:
184-
- unit_test
202+
- checkout_code
203+
204+
- build:
205+
name: build_production
206+
config: production
207+
requires:
208+
- checkout_code
185209

186210
- deploy:
187211
name: deploy_staging
212+
config: staging
188213
requires:
189-
- build
214+
- build_staging
190215
bucket: "<% index .Params `stagingFrontendHost` %>"
191216
region: "<% index .Params `region` %>"
192217
# Depending on your development flow you may want to also only deploy to staging on master.
@@ -198,8 +223,8 @@ workflows:
198223
- deploy:
199224
name: deploy_production
200225
requires:
201-
- build
202-
- deploy_staging
226+
- unit_test
227+
- build_production
203228
bucket: "<% index .Params `productionFrontendHost` %>"
204229
region: "<% index .Params `region` %>"
205230
filters:

README.md

Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
## Commit Zero
22

3-
This app is created to work with Commit Zero. You'll need to run the `stack` application against a `config.yaml` file to generate the code.
3+
This app is created to work with Commit Zero. You'll need to run the `zero` application against a `zero.yml` file to generate the code.
44

5-
### Stack Command
5+
### Zero Command
66

77
```bash
8-
stack -config <config file> <source directory> <destination directory>
8+
zero -config <config file> <source directory> <destination directory>
99
```
1010

1111
#### Config File
@@ -37,73 +37,62 @@ _Once you've templated this out, you can remove the above section from this READ
3737

3838
# <% .Name %>
3939

40-
## React App
40+
## Create React App
4141

4242
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4343

44-
## Available Scripts
44+
See full documentation [here](docs/create-react-app.md)
4545

46-
In the project directory, you can run:
46+
### Commands
4747

48-
### `yarn start`
48+
#### Install Dependencies
4949

50-
Runs the app in the development mode.<br />
51-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
52-
53-
The page will reload if you make edits.<br />
54-
You will also see any lint errors in the console.
55-
56-
### `yarn test`
57-
58-
Launches the test runner in the interactive watch mode.<br />
59-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
60-
61-
### `yarn build`
62-
63-
Builds the app for production to the `build` folder.<br />
64-
It correctly bundles React in production mode and optimizes the build for the best performance.
65-
66-
The build is minified and the filenames include the hashes.<br />
67-
Your app is ready to be deployed!
68-
69-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
70-
71-
### `yarn eject`
72-
73-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
50+
```zsh
51+
yarn
52+
```
7453

75-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
54+
#### Run locally
7655

77-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
56+
```zsh
57+
yarn start
58+
```
7859

79-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
60+
#### Run Tests
8061

81-
## Learn More
62+
```zsh
63+
yarn test
64+
```
8265

83-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
66+
## Backend App
8467

85-
To learn React, check out the [React documentation](https://reactjs.org/).
68+
To run the backend app locally all you need to do is build the container and run it alongside your app.
8669

87-
### Code Splitting
70+
### Backend Repo
8871

89-
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
72+
The corresponding backend for this app is [zero-deployable-backend](https://github.com/commitdev/zero-deployable-backend)
9073

91-
### Analyzing the Bundle Size
74+
```zsh
75+
git clone [email protected]:commitdev/zero-deployable-backend.git
76+
```
9277

93-
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
78+
### Docker
9479

95-
### Making a Progressive Web App
80+
Build the docker image locally and run it. We need to set a Pod name so that the frontend can display that data.
9681

97-
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
82+
```zsh
83+
docker build . -t zero-deployable-backend
9884

99-
### Advanced Configuration
85+
docker run -p 8080:8080 -e SERVER_PORT=8080 -e POD_NAME="Fake POD name." zero-deployable-backend
86+
```
10087

101-
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
88+
### Environment Configs
10289

103-
### Deployment
90+
These are set by `REACT_APP_CONFIG` enviroment variable at build time. This corresponds to a json file in the config directory.
10491

105-
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
92+
For example to build the staging site and host it you would use:
10693

107-
### `yarn build` fails to minify
94+
```zsh
95+
REACT_APP_CONFIG=staging yarn build
10896

109-
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
97+
serve -s build
98+
```

docs/create-react-app.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Create React App
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Available Scripts
6+
7+
In the project directory, you can run:
8+
9+
### `yarn start`
10+
11+
Runs the app in the development mode.<br />
12+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13+
14+
The page will reload if you make edits.<br />
15+
You will also see any lint errors in the console.
16+
17+
### `yarn test`
18+
19+
Launches the test runner in the interactive watch mode.<br />
20+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21+
22+
### `yarn build`
23+
24+
Builds the app for production to the `build` folder.<br />
25+
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
27+
The build is minified and the filenames include the hashes.<br />
28+
Your app is ready to be deployed!
29+
30+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31+
32+
### `yarn eject`
33+
34+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35+
36+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37+
38+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39+
40+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41+
42+
## Learn More
43+
44+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45+
46+
To learn React, check out the [React documentation](https://reactjs.org/).
47+
48+
### Code Splitting
49+
50+
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
51+
52+
### Analyzing the Bundle Size
53+
54+
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
55+
56+
### Making a Progressive Web App
57+
58+
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
59+
60+
### Advanced Configuration
61+
62+
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
63+
64+
### Deployment
65+
66+
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
67+
68+
### `yarn build` fails to minify
69+
70+
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

src/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import InfoPanel from "./components/Info";
77

88
// Set config based on the environment variable the build was run under.
99
let config = {};
10-
if (process.env.NODE_ENV === "production") {
10+
if (process.env.REACT_APP_CONFIG === "production") {
1111
config = require("./config/production.json");
12-
} else if (process.env.NODE_ENV === "staging") {
12+
} else if (process.env.REACT_APP_CONFIG === "staging") {
1313
config = require("./config/staging.json");
1414
} else {
1515
config = require("./config/development.json");

0 commit comments

Comments
 (0)