Skip to content

Commit b1318d9

Browse files
committed
Improve docs for install/usage
1 parent 6f4ab3e commit b1318d9

File tree

3 files changed

+85
-65
lines changed

3 files changed

+85
-65
lines changed

README.md

+9-33
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To do so, please read the guidelines in our [`CONTRIBUTING.md`](CONTRIBUTING.md)
1919

2020
Then check out some GitHub issues to see where you can help out.
2121

22-
## Developer installation guide
22+
## Installing
2323

2424
### Recommended install
2525

@@ -29,40 +29,16 @@ To make your life easier, you can just clone this repository and use our Docker
2929

3030
We wholeheartedly recommend against doing a custom install. You'll be spending more time configuring and less time being productive. But if you'd like to work that way, you can read our [custom install guide](docs/CUSTOM_INSTALL.md).
3131

32+
## Usage
3233

33-
### Serving Ember
34+
Have everything installed and ready to work? [Read our usage guides](docs/USAGE.md) to learn how to:
3435

35-
The Code Corps API is intended to work alongside a client written in Ember. For that purpose, the Rails application exposes all of its API endpoints behind an `api.` subdomain.
36-
37-
On the Ember client side of things, we use [`ember-cli-deploy`](https://github.com/ember-cli/ember-cli-deploy) with a `redis` plugin to deploy the client application to redis. Multiple revisions are maintained this way.
38-
39-
Any server request pointing to the main domain and not the `api.` subdomain is redirected to the API's `ember_index_controller#index`. There, depending on the remainder of the request path and the current environment, a specific revision of the Ember app's `index.html` is retrieved from redis and rendered. This `index.html` can be:
40-
* the development revision, if the current environment is development
41-
* a specific deployed revision in production if the request contains a revision parameter in SHORT_UUID format
42-
* the latest deployed revision in production if the request does not contain a revision parameter
43-
* a plain text string containing "INDEX NOT FOUND" if a revision was specified, but the key for the specified revision was not found by redis
44-
45-
46-
### Debugging
47-
48-
Because the app is running `foreman`, debugging using `pry` won't work the same way. If you want to use `pry`, you'll need to [debug remotely](https://github.com/nixme/pry-debugger#remote-debugging).
49-
50-
Add `binding.remote_pry` where you want to pause:
51-
52-
```ruby
53-
class UsersController < ApplicationController
54-
def index
55-
binding.remote_pry
56-
...
57-
end
58-
end
59-
```
60-
61-
Load a page or make a request that triggers the code. Connect to the session:
62-
63-
```shell
64-
$ docker-compose run web pry-remote
65-
```
36+
- Run normal Rails commands through Docker
37+
- Run tests
38+
- Stop and start the server, and rebuild Docker containers
39+
- Push changes to GitHub
40+
- Serve the Ember app's `index.html`
41+
- Debug with `pry-remote`
6642

6743
## Built with
6844

docs/DEFAULT_INSTALL.md

+3-32
Original file line numberDiff line numberDiff line change
@@ -61,40 +61,11 @@ Point your browser (or make a direct request) to `http://api.lvh.me/ping`. There
6161

6262
`lvh.me` resolves to `localhost` so you can use subdomains, like our `api` subdomain.
6363

64-
### Interacting with the app
64+
### Next steps
6565

66-
You'll notice we wrapped `docker-compose` earlier, but you'll generally want to use this to interact with the app.
66+
Now that you're set up, you should [read more about how to develop with the API](docs/USAGE.md).
6767

68-
- `bundle exec rails console``docker-compose run web rails console`
69-
- `bundle exec rake db:migrate``docker-compose run web rake db:migrate`
70-
- `bundle exec rake db:test:prepare``docker-compose run web rake db:test:prepare`
71-
- and so on...
72-
73-
We do have a couple other helper scripts:
74-
75-
- `bin/setup` → sets up the app
76-
- `bin/migrate` → migrates your database
77-
- `bin/reseed` → re-runs `rake db:seed_fu` to re-seed your database
78-
79-
### Guard and tests
80-
81-
You'll also notice that the `test` container we mentioned above is running `guard`. This means that file changes will be observed and tests re-run on those files.
82-
83-
You can certainly run `docker-console run test rspec spec`, but `guard` can help you by constantly watching for failing specs.
84-
85-
### Stopping, starting, and rebuilding
86-
87-
Need to stop the containers? Either `Ctrl+C` or in a seperate prompt run `docker-compose stop`.
88-
89-
To start the services again you can run `docker-compose up`, or `docker-compose start` to start the containers in a detached state.
90-
91-
If you ever need to rebuild you can run `docker-compose up --build`. Unless you've destroyed your Docker container images, this should be faster than the first run.
92-
93-
### Pushing changes
94-
95-
You can use `git` as you normally would, either on your own host machine or in Docker's `web` container.
96-
97-
### Issues
68+
### Issues installing?
9869

9970
Having trouble?
10071

docs/USAGE.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
### Interacting with the app
2+
3+
You'll notice we wrapped `docker-compose` earlier, but you'll generally want to use this to interact with the app.
4+
5+
- `bundle exec rails console``docker-compose run web rails console`
6+
- `bundle exec rake db:migrate``docker-compose run web rake db:migrate`
7+
- `bundle exec rake db:test:prepare``docker-compose run web rake db:test:prepare`
8+
- and so on...
9+
10+
We do have a couple other helper scripts:
11+
12+
- `bin/setup` → sets up the app
13+
- `bin/migrate` → migrates your database
14+
- `bin/reseed` → re-runs `rake db:seed_fu` to re-seed your database
15+
16+
17+
### Guard and tests
18+
19+
You'll also notice that the `test` container we mentioned above is running `guard`. This means that file changes will be observed and tests re-run on those files.
20+
21+
You can certainly run `docker-console run test rspec spec`, but `guard` can help you by constantly watching for failing specs.
22+
23+
24+
### Stopping and starting the server
25+
26+
Need to stop the containers? Either `Ctrl+C` or in a seperate prompt run `docker-compose stop`.
27+
28+
To start the services again you can run `docker-compose up`, or `docker-compose start` to start the containers in a detached state.
29+
30+
31+
### Rebuilding Docker containers
32+
33+
If you ever need to rebuild you can run `docker-compose up --build`. Unless you've destroyed your Docker container images, this should be faster than the first run.
34+
35+
36+
### Pushing changes
37+
38+
You can use `git` as you normally would, either on your own host machine or in Docker's `web` container.
39+
40+
41+
### Serving Ember
42+
43+
The Code Corps API is intended to work alongside a client written in Ember. For that purpose, the Rails application exposes all of its API endpoints behind an `api.` subdomain.
44+
45+
On the Ember client side of things, we use [`ember-cli-deploy`](https://github.com/ember-cli/ember-cli-deploy) with a `redis` plugin to deploy the client application to redis. Multiple revisions are maintained this way.
46+
47+
Any server request pointing to the main domain and not the `api.` subdomain is redirected to the API's `ember_index_controller#index`. There, depending on the remainder of the request path and the current environment, a specific revision of the Ember app's `index.html` is retrieved from redis and rendered. This `index.html` can be:
48+
* the development revision, if the current environment is development
49+
* a specific deployed revision in production if the request contains a revision parameter in SHORT_UUID format
50+
* the latest deployed revision in production if the request does not contain a revision parameter
51+
* a plain text string containing "INDEX NOT FOUND" if a revision was specified, but the key for the specified revision was not found by redis
52+
53+
54+
### Debugging
55+
56+
Because the app is running `foreman`, debugging using `pry` won't work the same way. If you want to use `pry`, you'll need to [debug remotely](https://github.com/nixme/pry-debugger#remote-debugging).
57+
58+
Add `binding.remote_pry` where you want to pause:
59+
60+
```ruby
61+
class UsersController < ApplicationController
62+
def index
63+
binding.remote_pry
64+
...
65+
end
66+
end
67+
```
68+
69+
Load a page or make a request that triggers the code. Connect to the session:
70+
71+
```shell
72+
$ docker-compose run web pry-remote
73+
```

0 commit comments

Comments
 (0)