Skip to content

Commit

Permalink
Merge pull request #6 from bryanlatten/feature-goss
Browse files Browse the repository at this point in the history
Dockerfile: Added goss
  • Loading branch information
bryanlatten authored Aug 30, 2016
2 parents 637bf98 + 2462cbd commit 4604f83
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ services:

script:
- docker build .
- docker build -f Dockerfile-alpine .
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@ ENV SIGNAL_BUILD_STOP=99 \
S6_KILL_FINISH_MAXTIME=5000 \
S6_KILL_GRACETIME=3000

# Slim the container from its pre-installed heft
RUN apt-get autoclean -y && \
# Upgrade base packages, then clean packaging leftover
RUN apt-get update && \
apt-get upgrade -yqq && \
apt-get install -yqq \
curl \
&& \
# Add goss for local testing
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.2.3/goss-linux-amd64 -o /usr/local/bin/goss && \
chmod +x /usr/local/bin/goss && \
apt-get remove --purge -yq curl && \
apt-get autoclean -y && \
apt-get autoremove -y && \
rm -rf /var/lib/{cache,log}/ && \
rm -rf /var/lib/apt/lists/ && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /tmp/* /var/tmp/*

# Overlay the root filesystem from this repo
Expand All @@ -22,6 +31,8 @@ COPY ./container/root /
RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C / && \
rm /tmp/s6-overlay-amd64.tar.gz

RUN goss -g goss.base.yaml validate

# NOTE: intentionally NOT using s6 init as the entrypoint
# This would prevent container debugging if any of those service crash
CMD ["/bin/bash", "/run.sh"]
6 changes: 6 additions & 0 deletions Dockerfile-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ RUN echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/r
sed \
bash \
grep \
curl \
&& \
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.2.3/goss-linux-amd64 -o /usr/local/bin/goss && \
chmod +x /usr/local/bin/goss && \
apk del curl && \
rm -rf /var/cache/apk/*

# Overlay the root filesystem from this repo
Expand All @@ -24,6 +28,8 @@ COPY ./container/root /
RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C / && \
rm /tmp/s6-overlay-amd64.tar.gz

RUN goss -g goss.base.yaml validate

# NOTE: intentionally NOT using s6 init as the entrypoint
# This would prevent container debugging if any of those service crash
CMD ["/bin/bash", "/run.sh"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ To inject changes just before runtime, shell scripts may be placed into the
`/etc/cont-init.d` folder.
As part of the process manager, these scripts are run in advance of the supervised processes. @see https://github.com/just-containers/s6-overlay#executing-initialization-andor-finalization-tasks

### Testing

Container tests itself as part of build process using [goss](https://github.com/aelsabbahy/goss) validator.
To add additional tests, overwrite (or extend) the `/goss.base.yaml` file.



### Advanced Modification

Expand Down
6 changes: 6 additions & 0 deletions container/root/goss.base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
command:
# Use a built-in S6 command to ensure it was installed
s6-true:
exit-status: 0
stderr: []
stdout: []

0 comments on commit 4604f83

Please sign in to comment.