Skip to content

Commit

Permalink
Add a new example
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksii Tsvietnov committed Mar 5, 2017
1 parent e4d8c96 commit 4189e5c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 5 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,39 @@ For instance, in case of using in a docker container, I personaly prefer to have

### The installation on top of CentOS Linux base image

This is an example of how it will look like in a Dockerfile with [centos:latest](https://hub.docker.com/_/centos/) as base image:
This is an example of how it would look like in a Dockerfile with [centos:latest](https://hub.docker.com/_/centos/) as base image:

```bash
FROM centos:latest

RUN curl -sSLfo /etc/trc http://vorakl.github.io/TrivialRC/trc && \
( cd /etc && curl -sSLf http://vorakl.github.io/TrivialRC/trc.sha256 | sha256sum -c ) && \
chmod +x /etc/trc && \
/etc/trc --version

COPY trc.d/ /etc/trc.d/
# Uncomment this if you have configuration files in trc.d/
#COPY trc.d/ /etc/trc.d/

ENTRYPOINT ["/etc/trc"]
```

### The installation on top of Alpine Linux base image

**Attention**! The Alpine Linux comes with Busybox but its functionality as a shell and as a few emulated tools *is not enough* for TrivialRC. To work in this distribution it requires two extra packages: `bash` and `procps`.
As a result, Dockerfile for the [alpine:edge](https://hub.docker.com/_/alpine/) base image will look like:
As a result, Dockerfile for the [alpine:edge](https://hub.docker.com/_/alpine/) base image would look like:

```bash
FROM alpine:edge
FROM alpine:latest

RUN apk add --no-cache bash procps

RUN wget -qP /etc/ http://vorakl.github.io/TrivialRC/trc && \
( cd /etc && wget -qO - http://vorakl.github.io/TrivialRC/trc.sha256 | sha256sum -c ) && \
chmod +x /etc/trc && \
/etc/trc --version

COPY trc.d/ /etc/trc.d/
# Uncomment this if you have configuration files in trc.d/
#COPY trc.d/ /etc/trc.d/

ENTRYPOINT ["/etc/trc"]
```
Expand All @@ -87,6 +91,8 @@ To get started there are provided a few examples:
* The example of using [configuration files](https://github.com/vorakl/TrivialRC/tree/master/examples/config-files) instead of command line parameters
* A docker container that registers itself in a [Service Discovery](https://github.com/vorakl/TrivialRC/tree/master/examples/docker-service-discovery) in the beginning, then starts some application and automatically removes the registration on exit
* This example launches [two different applications](https://github.com/vorakl/TrivialRC/tree/master/examples/docker-two-apps) inside one docker container and controls the availability both of them. If any of applications has stopped working by some reasons, the whole container will be stopped automatically with the appropriate exit status
* The example of building [docker base images](https://github.com/vorakl/TrivialRC/tree/master/examples/docker-base-images) with TrivialRC as an ENTRYPOINT


## The verbosity control

Expand Down
10 changes: 10 additions & 0 deletions examples/docker-base-images/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM alpine:edge

RUN apk add --no-cache bash procps

RUN wget -qP /etc/ http://vorakl.github.io/TrivialRC/trc && \
( cd /etc && wget -qO - http://vorakl.github.io/TrivialRC/trc.sha256 | sha256sum -c ) && \
chmod +x /etc/trc && \
/etc/trc --version

ENTRYPOINT ["/etc/trc"]
8 changes: 8 additions & 0 deletions examples/docker-base-images/Dockerfile.centos
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM centos:latest

RUN curl -sSLfo /etc/trc http://vorakl.github.io/TrivialRC/trc && \
( cd /etc && curl -sSLf http://vorakl.github.io/TrivialRC/trc.sha256 | sha256sum -c ) && \
chmod +x /etc/trc && \
/etc/trc --version

ENTRYPOINT ["/etc/trc"]
29 changes: 29 additions & 0 deletions examples/docker-base-images/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# The example of building docker base images with TrivialRC as an ENTRYPOINT

In this example, as base images were taken CentOS and Alpine.
Basically, it shows two different approaches which are specific for each distribution.

## Build

Run these commands from the directory with the example

```bash
$ docker build -t centos-base -f Dockerfile.centos .
$ docker build -t alpine-base -f Dockerfile.alpine .
```

## Test

Let's test that TrivialRC works as expected

```bash
$ docker run --rm -e RC_VERBOSE=true centos-base
2017-03-05 22:31:15 trc [main/1]: The wait policy: wait_any
2017-03-05 22:31:15 trc [main/1]: Trying to terminate sub-processes...
2017-03-05 22:31:15 trc [main/1]: Exited (exitcode=0)

$ docker run --rm -e RC_VERBOSE=true alpine-base
2017-03-05 22:31:29 trc [main/1]: The wait policy: wait_any
2017-03-05 22:31:29 trc [main/1]: Trying to terminate sub-processes...
2017-03-05 22:31:29 trc [main/1]: Exited (exitcode=0)
```

0 comments on commit 4189e5c

Please sign in to comment.