embark-docker/README.md

196 lines
3.7 KiB
Markdown
Raw Normal View History

2018-07-11 13:30:32 +00:00
# Embark for Docker
2018-07-24 23:56:07 +00:00
## Quick start
In a Bash shell:
``` shell
source <(curl 'https://raw.githubusercontent.com/embark-framework/embark-docker/master/run.sh')
2018-07-25 03:27:03 +00:00
run_embark demo
2018-07-24 23:56:07 +00:00
cd embark_demo
2018-07-25 03:27:03 +00:00
run_embark
2018-07-24 23:56:07 +00:00
```
With overrides:
``` shell
export EMBARK_DOCKER_EXTRA_RUN_OPTS='--rm'
export EMBARK_DOCKER_IMAGE=statusim/embark
export EMBARK_DOCKER_TAG=custom
export EMBARK_DOCKERFILE='https://github.com/embark-framework/embark-docker.git#some/branch'
2018-07-25 03:00:41 +00:00
export EMBARK_VERSION='embark-framework/embark#features/branch'
2018-07-24 23:56:07 +00:00
export NODE_TAG=10.7.0
export RUNNER='https://raw.githubusercontent.com/embark-framework/embark-docker/some/branch/run.sh'
docker build \
2018-07-25 03:02:27 +00:00
--build-arg EMBARK_VERSION=$EMBARK_VERSION \
--build-arg NODE_TAG=$NODE_TAG \
-t $EMBARK_DOCKER_IMAGE:$EMBARK_DOCKER_TAG \
$EMBARK_DOCKERFILE
2018-07-24 23:56:07 +00:00
source <(curl $RUNNER)
2018-07-25 03:27:03 +00:00
run_embark demo
2018-07-24 23:56:07 +00:00
cd embark_demo
2018-07-25 03:27:03 +00:00
run_embark
2018-07-24 23:56:07 +00:00
```
2018-07-25 20:52:49 +00:00
Review the
[Dockerfile](https://github.com/embark-framework/embark-docker/blob/master/Dockerfile)
and
[run.sh](https://github.com/embark-framework/embark-docker/blob/master/run.sh#L66-L70)
for all possible overrides.
2018-07-24 23:56:07 +00:00
2018-07-25 03:27:03 +00:00
### Shortcuts
2018-07-25 20:17:31 +00:00
These are equivlent:
``` shell
run_embark
```
``` shell
run_embark run
```
``` shell
run_embark embark run
```
The following are also equivalent:
2018-07-25 03:27:03 +00:00
``` shell
run_embark demo
```
``` shell
run_embark embark demo
```
2018-07-25 20:17:31 +00:00
The same is true for the rest of the `embark` commands. To see the full list:
2018-07-25 03:27:03 +00:00
``` shell
2018-07-25 20:17:31 +00:00
run_embark --help
2018-07-25 03:27:03 +00:00
```
2018-07-25 20:17:39 +00:00
### Compound commands
A single command with options can be supplied directly:
2018-07-25 03:27:03 +00:00
``` shell
2018-07-25 20:17:39 +00:00
run_embark bash
```
``` shell
run_embark ps -ef
```
Compound commands should be passed to `bash -[i]c`:
``` shell
run_embark bash -c 'exec bash << "SCRIPT"
simple_nodeenv 10.7.0 my_node
node --version
echo $(which node)
npm i -g http-server
exec http-server -p 10000
SCRIPT
'
2018-07-25 03:27:03 +00:00
```
2018-07-25 20:17:39 +00:00
When executing compound commands via `docer exec` in a running embark
container, `su-exec` and `bash -ic` can be used together:
2018-07-25 03:27:03 +00:00
``` shell
2018-07-25 20:17:39 +00:00
docker exec -it <container-id> su-exec embark \
bash -ic 'exec bash << "SCRIPT"
2018-07-25 20:52:57 +00:00
nac my_node
2018-07-25 20:17:39 +00:00
exec http-server -p 10001
SCRIPT
'
2018-07-25 03:27:03 +00:00
```
2018-07-25 20:17:39 +00:00
Alternatively, to go non-interactive, manually source the embark user's
`.bash_env`:
2018-07-25 03:27:03 +00:00
``` shell
2018-07-25 20:17:39 +00:00
docker exec -it <container-id> su-exec embark \
bash -c 'exec bash << "SCRIPT"
. ~/.bash_env
2018-07-25 20:52:57 +00:00
nvm_load no-auto-lts
nvm install v10.6.0
echo $(which node)
2018-07-25 20:17:39 +00:00
npm i -g http-server
exec http-server -p 10002
SCRIPT
'
2018-07-25 03:27:03 +00:00
```
2018-07-11 13:30:32 +00:00
## Updating versions
* Open `Dockerfile`
2018-07-24 23:55:54 +00:00
* On the `ARG` directives, update necessary versions.
2018-07-11 13:30:32 +00:00
## Building
2018-07-24 23:55:40 +00:00
Building requires Docker to be installed on your local machine.
2018-07-11 18:53:08 +00:00
### Scripted
If you have Ruby installed in your system, run:
2018-07-11 13:30:32 +00:00
```
2018-07-11 18:53:08 +00:00
$ ruby script/build
```
To release, add `--release` as a parameter of the build script.
### Manually
2018-07-25 20:52:49 +00:00
Building and releasing manually isn't too hard either, but there are a couple
steps.
2018-07-11 18:53:08 +00:00
#### Tags
2018-07-25 20:52:49 +00:00
To facilitate the images being found, we tag them with the following rules (as
an example, the `3.1.5` version will be used.)
2018-07-11 18:53:08 +00:00
- Tag with `statusim/embark:latest` if `3.1.5` is the latest version.
- Tag with `statusim/embark:3.1.5`
- Tag with `statusim/embark:3.1` if `3.1.5` is the highest patch level on `3.1`
2018-07-25 20:52:49 +00:00
- Tag with `statusim/embark:3` if `3.1.5` is the highest minor and patch level
on `3`
2018-07-11 18:53:08 +00:00
#### Generating the image
To generate the image, run:
```
docker build . -t statusim/embark:<version> [...tags]
2018-07-11 13:30:32 +00:00
```
## Releasing
Releasing requires that you're authenticated to Docker Hub. To do so, run:
```
$ docker login
```
2018-07-11 18:53:08 +00:00
### Scripted
If you have Ruby installed in your system, run:
```
$ ruby script/build --release
```
### Manual
2018-07-25 20:52:49 +00:00
Pushing the tags manually implies that the image has been previously built. To
push your local images, run:
2018-07-11 13:30:32 +00:00
```
2018-07-11 18:53:08 +00:00
docker push statusim/embark:version
2018-07-11 13:30:32 +00:00
```