Skip to content

Commit 4189e5c

Browse files
author
Oleksii Tsvietnov
committed
Add a new example
1 parent e4d8c96 commit 4189e5c

File tree

4 files changed

+58
-5
lines changed

4 files changed

+58
-5
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,39 @@ For instance, in case of using in a docker container, I personaly prefer to have
4646

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

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

5151
```bash
5252
FROM centos:latest
5353

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

58-
COPY trc.d/ /etc/trc.d/
59+
# Uncomment this if you have configuration files in trc.d/
60+
#COPY trc.d/ /etc/trc.d/
5961

6062
ENTRYPOINT ["/etc/trc"]
6163
```
6264

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

6567
**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`.
66-
As a result, Dockerfile for the [alpine:edge](https://hub.docker.com/_/alpine/) base image will look like:
68+
As a result, Dockerfile for the [alpine:edge](https://hub.docker.com/_/alpine/) base image would look like:
6769

6870
```bash
69-
FROM alpine:edge
71+
FROM alpine:latest
7072

7173
RUN apk add --no-cache bash procps
7274

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

77-
COPY trc.d/ /etc/trc.d/
80+
# Uncomment this if you have configuration files in trc.d/
81+
#COPY trc.d/ /etc/trc.d/
7882

7983
ENTRYPOINT ["/etc/trc"]
8084
```
@@ -87,6 +91,8 @@ To get started there are provided a few examples:
8791
* The example of using [configuration files](https://github.com/vorakl/TrivialRC/tree/master/examples/config-files) instead of command line parameters
8892
* 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
8993
* 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
94+
* The example of building [docker base images](https://github.com/vorakl/TrivialRC/tree/master/examples/docker-base-images) with TrivialRC as an ENTRYPOINT
95+
9096

9197
## The verbosity control
9298

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM alpine:edge
2+
3+
RUN apk add --no-cache bash procps
4+
5+
RUN wget -qP /etc/ http://vorakl.github.io/TrivialRC/trc && \
6+
( cd /etc && wget -qO - http://vorakl.github.io/TrivialRC/trc.sha256 | sha256sum -c ) && \
7+
chmod +x /etc/trc && \
8+
/etc/trc --version
9+
10+
ENTRYPOINT ["/etc/trc"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM centos:latest
2+
3+
RUN curl -sSLfo /etc/trc http://vorakl.github.io/TrivialRC/trc && \
4+
( cd /etc && curl -sSLf http://vorakl.github.io/TrivialRC/trc.sha256 | sha256sum -c ) && \
5+
chmod +x /etc/trc && \
6+
/etc/trc --version
7+
8+
ENTRYPOINT ["/etc/trc"]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# The example of building docker base images with TrivialRC as an ENTRYPOINT
2+
3+
In this example, as base images were taken CentOS and Alpine.
4+
Basically, it shows two different approaches which are specific for each distribution.
5+
6+
## Build
7+
8+
Run these commands from the directory with the example
9+
10+
```bash
11+
$ docker build -t centos-base -f Dockerfile.centos .
12+
$ docker build -t alpine-base -f Dockerfile.alpine .
13+
```
14+
15+
## Test
16+
17+
Let's test that TrivialRC works as expected
18+
19+
```bash
20+
$ docker run --rm -e RC_VERBOSE=true centos-base
21+
2017-03-05 22:31:15 trc [main/1]: The wait policy: wait_any
22+
2017-03-05 22:31:15 trc [main/1]: Trying to terminate sub-processes...
23+
2017-03-05 22:31:15 trc [main/1]: Exited (exitcode=0)
24+
25+
$ docker run --rm -e RC_VERBOSE=true alpine-base
26+
2017-03-05 22:31:29 trc [main/1]: The wait policy: wait_any
27+
2017-03-05 22:31:29 trc [main/1]: Trying to terminate sub-processes...
28+
2017-03-05 22:31:29 trc [main/1]: Exited (exitcode=0)
29+
```

0 commit comments

Comments
 (0)