Skip to content
This repository was archived by the owner on Jun 12, 2018. It is now read-only.

Commit fb9a6e6

Browse files
committed
Many docs in preparation of a new relase
1 parent 3e2f32b commit fb9a6e6

File tree

9 files changed

+287
-127
lines changed

9 files changed

+287
-127
lines changed

docs/buildpacks/custom.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@ In order to use a custom buildpack you can build your own images with it, or
55
you can bind mount its directory with Devstep containers.
66

77
For example, you can place your buildpack sources at `$HOME/projects/my-buildpack`
8-
and add the following line to your `$HOME/.devsteprc` so that it is available to
8+
and add the following line to your `$HOME/devstep.yml` so that it is available to
99
all Devstep environments:
1010

11-
```sh
12-
DEVSTEP_RUN_OPTS="${DEVSTEP_RUN_OPTS} -v $HOME/projects/my-buildpack:/.devstep/buildpacks/my-buildpack"
11+
```yaml
12+
volumes:
13+
- '{{env "HOME"}}/projects/my-buildpack:/.devstep/buildpacks/my-buildpack'
1314
```
1415
1516
If you want to use a custom base image, you can add the following line to your
16-
project's `.devsteprc` or `$HOME/.devsteprc`:
17+
project's `devstep.yml` or `$HOME/devstep.yml`:
1718

1819
```sh
19-
DEVSTEP_SOURCE_IMAGE="my-user/an-image:a-tag"
20+
source_image: 'my-user/an-image:a-tag'
2021
```
2122

2223
For more information on creating buildpacks, please have a look at

docs/cli/aliases-and-binstubs.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# CLI Aliases and Binstubs
2+
3+
The [`commands` configurations set from `devstep.yml` files](configuration)
4+
can be used to enable some powerful aliases in case you need to frequently
5+
run one off commands against a previously build project image.
6+
7+
For example, you can keep a terminal session with a Rails server running on a
8+
tab and on a separate tab you can keep a `devstep hack` session open for
9+
development tasks so you can easily run tests or execute some `rake` tasks.
10+
11+
By specifying the following command on your `devstep.yml` you'll be able to
12+
`devstep run server` instead of `devstep run -p 3000:3000 -- bundle exec rails server`:
13+
14+
```yaml
15+
commands:
16+
server:
17+
cmd: ["bundle", "exec", "rails", "server"]
18+
publish: ["3000:3000"]
19+
```
20+
21+
## Using binstubs
22+
23+
Given the configuration above, you might also want to skip the `devstep run`
24+
part from `devstep run server` while keeping the specified configs like published
25+
ports or volumes specified on `devstep.yml` files.
26+
27+
By running the `devstep binstubs` command from your project's root, a bash script
28+
will be created under `.devstep/bin` for each specified command, so you are a `export PATH=".devstep/bin:$PATH"`
29+
away from running just `server` using the configs outlined above.

docs/cli/commands.md

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# CLI Commands
22
--------------
33

4-
# TODO: Update to reflect the new yaml configs
4+
1. [Hack](#user-content-hack)
5+
1. [Build](#user-content-build)
6+
1. [Boostrap](#user-content-bootstrap)
7+
1. [Other commands](#user-content-other-commands)
58

6-
## `devstep hack`
9+
--------------
10+
11+
## **Hack**
12+
13+
**Command: `devstep hack [OPTIONS]`**
714

815
This is the easiest way to get started with Devstep. By running the command
916
from your project's root, Devstep will:
1017

11-
1. Create a Docker container based on `fgrehm/devstep:v0.1.0` with project
18+
1. Create a Docker container based on `fgrehm/devstep:v0.2.0` with project
1219
sources bind mounted at `/workspace`.
1320
2. Detect and install project's dependencies on the new container using the
1421
available buildpacks.
@@ -17,15 +24,27 @@ from your project's root, Devstep will:
1724
Once you `exit` the `bash` session, the container will be garbage collected
1825
(aka `docker rm`ed).
1926

20-
In case you need to provide additional parameters to the underlying `docker run`
21-
command you can use the `-r` flag. For example, `devstep hack -r "-p 80:8080"` will
22-
redirect the `8080` port on your host to the port `8080` within the container.
27+
**Options**
28+
29+
* `-w, --working_dir` - Working directory inside the container
30+
* `-p, --publish` - Publish a container's port to the host (hostPort:containerPort)
31+
* `--link` - Add link to another container (name:alias)
32+
* `-e, --env` - Set environment variables
33+
* `--privileged` - Give extended privileges to this container
2334

24-
## `devstep build`
35+
**Example**
36+
37+
```sh
38+
devstep hack -p 80:8080 --link postgres:db --link memcached:mc -e DEVSTEP_BUNDLER_VERSION='1.6.0'
39+
```
40+
41+
## **Build**
42+
43+
**Command: `devstep build`**
2544

2645
By running the command from your project's root, Devstep will:
2746

28-
1. Create a Docker container based on `fgrehm/devstep:v0.1.0` with project
47+
1. Create a Docker container based on `fgrehm/devstep:v0.2.0` with project
2948
sources bind mounted at `/workspace`.
3049
2. Detect and install project's dependencies on the new container using the
3150
available buildpacks.
@@ -34,7 +53,7 @@ By running the command from your project's root, Devstep will:
3453

3554
The `devstep/<PROJECT>` images act like snapshots of your project dependencies
3655
and will be used as the source image for subsequent `devstep` commands instead
37-
of the `fgrehm/devstep:v0.1.0` image.
56+
of the `fgrehm/devstep:v0.2.0` image.
3857

3958
For example, running a `devstep hack` after building the image will use `devstep/<PROJECT>:latest`
4059
as the base container for new "hacking sessions" so that you don't have to build
@@ -52,7 +71,9 @@ on the host machine as a Docker volume in order to work on the project.
5271
docker run -ti -v `pwd`:/workspace devstep/<PROJECT>
5372
```
5473

55-
## `devstep bootstrap`
74+
## **Bootstrap**
75+
76+
**Command: `devstep bootstrap [OPTIONS]`**
5677

5778
As you might have guessed, this command can be used bootstrap new projects without
5879
cluttering your machine with development tools just to scaffold a new project.
@@ -62,11 +83,17 @@ bind mounted as `/workspace` on the container and you'll have to manually config
6283
the tools required to scaffold your new project. You can even force a specific
6384
buildpack to run from there.
6485

86+
**Options**
87+
88+
* `-r, --repository` - Repository name used when commiting the Docker image.
89+
90+
**Example**
91+
6592
For example, scaffolding a new Rails project means:
6693

6794
```sh
6895
cd $HOME/projects # or whatever directory you keep your projects
69-
devstep bootstrap -w my_app
96+
devstep bootstrap -r my_app
7097

7198
build-project -b ruby
7299
reload-env
@@ -97,13 +124,13 @@ approach, replacing the Ruby / Rails specifics with the platform / framework
97124
of choice.
98125

99126

100-
## Other commands
127+
## **Other commands**
101128

102-
* `clean` -> Remove all images built for the current project
103-
* `pristine` -> Rebuild current project associated Docker image from scratch
104-
* `run` -> Run a one off command against the current source image
105-
* `images` -> Display images available for the current project
106-
* `ps` -> List all containers associated with the current project
107-
* `info` -> Show some information about the current project
129+
* `info` - Show information about the current environment
130+
* `run` - Run a one off command against the current base image
131+
* `binstubs` - Generate binstubs for the commands specified on devstep.yml
132+
* `clean` - Remove previously built images for the current environment
133+
* `pristine` - Rebuild project image from scratch
134+
* `help, h` - Shows a list of commands or help for one command
108135

109136
For the most up-to-date list of supported commands, run `devstep --help`.

docs/cli/configuration.md

Lines changed: 65 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,72 @@
11
# CLI Configuration
22
-------------------
33

4-
# TODO: Update to reflect the new yaml configs
5-
6-
Devstep's CLI has a simple configuration mechanism in the form of Bash variables
7-
that can be used to customize its behavior globally or for a specific project.
8-
9-
The available options along with its defaults are:
10-
11-
```sh
12-
# Starting point for project images
13-
DEVSTEP_SOURCE_IMAGE="fgrehm/devstep:v0.1.0"
14-
15-
# Root path to the project being built
16-
DEVSTEP_WORKSPACE_PATH=`pwd`
17-
18-
# Name of the project being worked on
19-
DEVSTEP_WORKSPACE_NAME=$(basename ${DEVSTEP_WORKSPACE_PATH})
20-
21-
# Name of Docker repository to use for the project
22-
DEVSTEP_WORKSPACE_REPO="devstep/${DEVSTEP_WORKSPACE_NAME}"
23-
24-
# Host path for keeping devstep cached packages
25-
DEVSTEP_CACHE_PATH="/tmp/devstep/cache"
26-
27-
# Global options for `docker run`s
28-
DEVSTEP_RUN_OPTS=
29-
30-
# `devstep hack` specific options for `docker run`
31-
DEVSTEP_HACK_RUN_OPTS=
4+
Devstep's CLI has a configuration mechanism in the form of [YAML](http://www.yaml.org/)
5+
files that can be used to customize its behavior globally or for a specific project.
6+
7+
The available options are described below:
8+
9+
```yaml
10+
# The Docker repository to keep images built by devstep
11+
# DEFAULT: 'devstep/<CURRENT_DIR_NAME>'
12+
repository: 'repo/name'
13+
14+
# The image used by devstep when building environments from scratch
15+
# DEFAULT: 'fgrehm/devstep:v0.2.0'
16+
source_image: 'source/image:tag'
17+
18+
# The host cache dir that gets mounted inside the container at `/.devstep/cache`
19+
# for speeding up the dependencies installation process.
20+
# DEFAULT: '/tmp/devstep/cache'
21+
cache_dir: '{{env "HOME"}}/devstep/cache'
22+
23+
# The directory where project sources should be mounted inside the container.
24+
# DEFAULT: '/workspace'
25+
working_dir: '/.devstep/gocode/src/github.com/fgrehm/devstep-cli'
26+
27+
# Link to other existing containers (like a database for example).
28+
# Please note that devstep won't start the associated containers automatically
29+
# and an error will be raised in case the linked container does not exist or
30+
# if it is not running.
31+
# DEFAULT: <empty>
32+
links:
33+
- "postgres:db"
34+
- "memcached:mc"
35+
36+
# Additional Docker volumes to share with the container.
37+
# DEFAULT: <empty>
38+
volumes:
39+
- "/path/on/host:/path/on/guest"
40+
41+
# Environment variables.
42+
# DEFAULT: <empty>
43+
environment:
44+
RAILS_ENV: "development"
45+
46+
# Custom command aliases that can be used with `devstep run` to save some
47+
# typing. It is also used for generating project specific binstubs.
48+
# DEFAULT: <empty>
49+
commands:
50+
# This can be run with `devstep run server`
51+
server:
52+
cmd: ["rails", "server"]
53+
# Here you can use some of the configs described above
54+
publish: ["3000:3000"]
55+
volumes:
56+
- '{{env "HOME"}}/certs/some-certificate.crt:/.devstep/some-certificate.crt'
57+
- '{{env "HOME"}}/projects/some-gem-sources:/.devstep/some-gem-sources'
58+
links:
59+
- 'redis:redis'
60+
environment:
61+
RAILS_ENV: "hacking"
62+
ruby:
63+
# No custom options, used only for generating binstubs
3264
```
3365

3466
During a `devstep` command run, the CLI will start by loading global config
35-
options from `$HOME/.devsteprc` and project specific options from a `.devsteprc`
36-
file located on the directory where the command is run.
37-
38-
Please note that to get project specific configs to be "merged" with global options
39-
for `docker run`s, you need to prepend your project configs with the previously
40-
defined value that might have been set on the global configuration file.
41-
42-
For example, if you want to configure a project to always link a `devstep hack`
43-
container with a PostgreSQL database, you can add the following to your project's
44-
`.devsteprc`:
45-
46-
```sh
47-
DEVSTEP_HACK_RUN_OPTS="${DEVSTEP_HACK_RUN_OPTS} --link postgresql:db"
48-
```
49-
50-
To figure out what are the configured values for a specific project, you can run
51-
`devstep info`.
52-
53-
## Disabling cache
67+
options from `$HOME/devstep.yml` and project specific options from a `devstep.yml`
68+
file located on the directory where the command is run and will merge them before
69+
creating containers.
5470

55-
To disable the caching functionality you can set it to a blank string (`DEVSTEP_CACHE_PATH=""`)
56-
on your `$HOME/.devsteprc`.
71+
To figure out what are the configured values for a specific project after
72+
merging settings you can run `devstep info`.

docs/cli/installation.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
# CLI Installation
22
------------------
33

4-
The CLI is a simple Bash script that you can download directly from a GitHub
5-
tagged release, place on a directory available on your `PATH` and make it
6-
executable.
4+
The CLI is [written in Golang](https://github.com/fgrehm/devstep-cli) and precompiled
5+
binaries are available for each GitHub tagged release. Installing it is a matter
6+
of downloading it from GitHub, placing the binary on a directory available on your
7+
`PATH` and making it executable.
78

89
This one liner can handle it for you assuming that `$HOME/bin` is available
910
on your `PATH`:
1011

1112
```sh
12-
# TODO: Update to new cli repo
13-
L=$HOME/bin/devstep && curl -sL https://github.com/fgrehm/devstep/raw/v0.1.0/devstep > $L && chmod +x $L
13+
L=$HOME/bin/devstep && curl -sL https://github.com/fgrehm/devstep-cli/raw/v0.1.0/devstep > $L && chmod +x $L
1414
```
1515

16-
Please note that the CLI currently interacts with the `docker` command, so make
17-
sure you have it installed and that your user is capable to run `docker` commands
18-
[without `sudo`](http://docs.docker.io/installation/ubuntulinux/#giving-non-root-access).
16+
Please note that the CLI is currently limited to connecting to a local `/var/run/docker.sock`
17+
socket only and the user that runs `devstep` commands will need [non-root access to it](http://docs.docker.io/installation/ubuntulinux/#giving-non-root-access).
18+
Support for execution over TCP is likely to be added at some point.
19+
1920

2021
> **IMPORTANT**: A `developer` user will be used by Devstep and it assumes your
2122
user and group ids are equal to `1000` when using the CLI or the container's init
@@ -29,7 +30,13 @@ Docker adds support for user namespaces ([#6600](https://github.com/dotcloud/doc
2930

3031
> The `1000` id was chosen because it is the default uid / gid of Ubuntu Desktop users
3132
that are created during the installation process. To work around this limitation
32-
you can build your own image with the appropriate ids and add a `DEVSTEP_SOURCE_IMAGE=<YOUR-IMAGE>`
33-
line to your `~/.devsteprc` so that the image is used as a source for your projects.
33+
you can build your own image with the appropriate ids and add a `source_image: '<YOUR-IMAGE>:<OPTIONAL-TAG>'`
34+
line to your `~/devstep.yml` so that the image is used as a source for your projects.
35+
36+
## Bash autocomplete
37+
38+
An autocompletion script can be installed using the one liner below:
3439

35-
# TODO: Update above to reflect the new yaml configs
40+
```sh
41+
curl -sL https://github.com/codegangsta/cli/raw/master/autocomplete/bash_autocomplete | sed 's/$PROG/devstep/' | sudo tee /etc/bash_completion.d/devstep
42+
```

docs/cli/plugins.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# CLI Plugins
2+
-----------
3+
4+
Devstep's CLI has an experimental support for plugins in the form of JavaScript
5+
files that can be used to hook into the CLI runtime to modify its configuration
6+
at specific points during commands execution.
7+
8+
Plugins should be installed to `$HOME/devstep/plugins/<PLUGIN_NAME>/plugin.js`
9+
on the machine that is executing `devstep` commands and the only requirement is
10+
that a plugin folder should have a `plugin.js` file.
11+
12+
## Plugin API
13+
14+
The current functionality is very rudimentary and is likely to be changed so right
15+
now it is best explained by the [squid3-ssl proxy](https://github.com/fgrehm/devstep-squid3-ssl)
16+
plugin source which is currently the plugin available:
17+
18+
```js
19+
// `_currentPluginPath` is the host path where the JavaScript file is located
20+
// and is provided by Devstep's CLI plugin runtime, we keep its value on a
21+
// separate variable because its value gets changed for each plugin that
22+
// gets loaded.
23+
squidRoot = _currentPluginPath;
24+
25+
// squidShared is the path were squid will keep both downloaded files on the host
26+
// machine and also the generated self signed certificate so that Devstep
27+
// containers can trust.
28+
squidShared = squidRoot + "/shared";
29+
30+
// Hook into the `configLoaded` event that gets triggered right after configuration
31+
// files are loaded (eg: `$HOME/devstep.yml` and `CURRENT_DIR/devstep.yml`)
32+
devstep.on('configLoaded', function(config) {
33+
config
34+
// Link CLI created containers with the squid container
35+
.addLink('squid3:squid3.dev')
36+
// Share the certificate file with Devstep containers
37+
.addVolume(squidShared + '/certs/squid3.dev.crt:/usr/share/ca-certificates/squid3.dev.crt')
38+
.setEnv('HTTPS_PROXY_CERT', 'squid3.dev.crt');
39+
// Inject the script that will trust the squid container certificate
40+
.addVolume(squidRoot + '/proxy.sh:/etc/my_init.d/proxy.sh')
41+
42+
// Sets environmental variables so that programs make use of the cache
43+
.setEnv('http_proxy', 'http://squid3.dev:3128')
44+
.setEnv('https_proxy', 'http://squid3.dev:3128')
45+
});
46+
```
47+
48+
The code above is the equivalent of passing in `-e`, `-v` and `--link` parameters
49+
to `devstep` commands.
50+
51+
> The current functionality provided by the plugin runtime is pretty rudimentary
52+
so if you have ideas for other plugins that you think would be useful, feel free to
53+
reach out on the [CLI issue tracker](https://github.com/fgrehm/devstep-cli/issues/new)
54+
or on [Gitter](https://gitter.im/fgrehm/devstep) so that it can be further discussed
55+
as it will likely involve changes on the CLI itself.

0 commit comments

Comments
 (0)