Skip to content

Commit c69abb0

Browse files
authored
Merge pull request #11 from bryanlatten/feature-centos
Centos: added as variant
2 parents 195e1c2 + bf88a53 commit c69abb0

File tree

10 files changed

+117
-15
lines changed

10 files changed

+117
-15
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ services:
66
script:
77
- docker build .
88
- docker build -f Dockerfile-alpine .
9+
- docker build -f Dockerfile-centos .

Dockerfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM ubuntu:16.04
2-
MAINTAINER Bryan Latten <[email protected]>
2+
LABEL Maintainer="Bryan Latten <[email protected]>"
33

44
# Use in multi-phase builds, when an init process requests for the container to gracefully exit, so that it may be committed
55
# Used with alternative CMD (worker.sh), leverages supervisor to maintain long-running processes
@@ -8,14 +8,18 @@ ENV SIGNAL_BUILD_STOP=99 \
88
S6_KILL_FINISH_MAXTIME=5000 \
99
S6_KILL_GRACETIME=3000 \
1010
S6_VERSION=v1.18.1.5 \
11-
GOSS_VERSION=v0.2.4
11+
GOSS_VERSION=v0.2.5
1212

1313
# Ensure scripts are available for use in next command
14-
COPY ./container/root/security_updates.sh / \
15-
./container/root/clean.sh /
14+
COPY ./container/root/scripts/* /scripts/
1615

16+
# - Symlink variant-specific scripts to default location
1717
# - Upgrade base security packages, then clean packaging leftover
18-
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
18+
# - Add S6 for zombie reaping, boot-time coordination, signal transformation/distribution: @see https://github.com/just-containers/s6-overlay#known-issues-and-workarounds
19+
# - Add goss for local, serverspec-like testing
20+
RUN ln -s /scripts/clean_ubuntu.sh /clean.sh && \
21+
ln -s /scripts/security_updates_ubuntu.sh /security_updates.sh && \
22+
echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
1923
/bin/bash -e /security_updates.sh && \
2024
apt-get install -yqq \
2125
curl \

Dockerfile-alpine

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM alpine:3.4
2-
MAINTAINER Bryan Latten <[email protected]>
2+
LABEL Maintainer="Bryan Latten <[email protected]>"
33

44
# Use in multi-phase builds, when an init process requests for the container to gracefully exit, so that it may be committed
55
# Used with alternative CMD (worker.sh), leverages supervisor to maintain long-running processes
@@ -8,7 +8,10 @@ ENV SIGNAL_BUILD_STOP=99 \
88
S6_KILL_FINISH_MAXTIME=5000 \
99
S6_KILL_GRACETIME=3000 \
1010
S6_VERSION=v1.18.1.5 \
11-
GOSS_VERSION=v0.2.3
11+
GOSS_VERSION=v0.2.5
12+
13+
# Ensure scripts are available for use in next command
14+
COPY ./container/root/scripts/* /scripts/
1215

1316
RUN echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories && \
1417
apk update && \

Dockerfile-centos

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM centos:7
2+
LABEL Maintainer="Bryan Latten <[email protected]>"
3+
4+
# Use in multi-phase builds, when an init process requests for the container to gracefully exit, so that it may be committed
5+
# Used with alternative CMD (worker.sh), leverages supervisor to maintain long-running processes
6+
ENV SIGNAL_BUILD_STOP=99 \
7+
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
8+
S6_KILL_FINISH_MAXTIME=5000 \
9+
S6_KILL_GRACETIME=3000 \
10+
S6_VERSION=v1.18.1.5 \
11+
GOSS_VERSION=v0.2.5
12+
13+
# Ensure scripts are available for use in next command
14+
COPY ./container/root/scripts/* /scripts/
15+
16+
# - Symlink variant-specific scripts to default location
17+
# - Upgrade base security packages, then clean packaging leftover
18+
# - Add S6 for zombie reaping, boot-time coordination, signal transformation/distribution: @see https://github.com/just-containers/s6-overlay#known-issues-and-workarounds
19+
# - Add goss for local, serverspec-like testing
20+
RUN ln -s /scripts/clean_centos.sh /clean.sh && \
21+
ln -s /scripts/security_updates_centos.sh /security_updates.sh && \
22+
/bin/bash -e /security_updates.sh && \
23+
/bin/bash -e /clean.sh && \
24+
curl -L https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}/s6-overlay-amd64.tar.gz -o /tmp/s6.tar.gz && \
25+
tar xzf /tmp/s6.tar.gz -C / --exclude="./bin" --exclude="./sbin" && \
26+
tar xzf /tmp/s6.tar.gz -C /usr ./bin ./sbin && \
27+
rm -f /tmp/s6.tar.gz && \
28+
curl -L https://github.com/aelsabbahy/goss/releases/download/${GOSS_VERSION}/goss-linux-amd64 -o /usr/local/bin/goss && \
29+
chmod +x /usr/local/bin/goss
30+
31+
# Overlay the root filesystem from this repo
32+
COPY ./container/root /
33+
34+
RUN goss -g goss.base.yaml validate
35+
36+
# NOTE: intentionally NOT using s6 init as the entrypoint
37+
# This would prevent container debugging if any of those service crash
38+
CMD ["/bin/bash", "/run.sh"]

README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@
55

66
https://hub.docker.com/r/behance/docker-base/tags/
77

8-
Ubuntu used by default, Alpine builds also available tagged as `-alpine`
8+
Provides base OS, security patches, and tools for quick and easy spinup.
99

10-
Provides base OS, patches and stable nginx for quick and easy spinup.
1110

12-
[S6](https://github.com/just-containers/s6-overlay) process supervisor is used for `only` for zombie reaping (as PID 1), boot coordination, and termination signal translation
11+
### Variants
1312

14-
[Goss](https://github.com/aelsabbahy/goss) is used for build-time testing
13+
Ubuntu container OS is in use by default
14+
15+
— Alpine builds available tagged as `-alpine`
16+
— Centos builds available tagged as `-centos`
17+
18+
19+
### Tools
20+
21+
- [S6](https://github.com/just-containers/s6-overlay) process supervisor is used for `only` for zombie reaping (as PID 1), boot coordination, and termination signal translation
22+
- [Goss](https://github.com/aelsabbahy/goss) is used for build-time testing
1523

1624
### Expectations
1725

@@ -20,8 +28,21 @@ For programmatic switches, create the service in `/etc/services-available`, and
2028

2129
### Security
2230

23-
For Ubuntu-based variants, a convenience script is provided for security-only package updates. To run:
24-
`/bin/bash -e /security_updates.sh`
31+
A convenience script is provided for security-only package updates.
32+
33+
On Ubuntu and CentOS-based variants, run:
34+
```/bin/bash -e /security_updates.sh```
35+
36+
This file is actually a symlink to the variant-specific script contained in the `/scripts` folder
37+
38+
### Packaging
39+
40+
A convenience script is provided for post-package installation cleanup
41+
42+
On Ubuntu and CentOS-based variants, run:
43+
```/bin/bash -e /clean.sh```
44+
45+
This file, like security_updates (above) is actually a symlink to the variant-specific script contained in the `/scripts` folder
2546

2647

2748
### Environment Variables
@@ -75,3 +96,4 @@ Directory | Use
7596
`/etc/services.d/` | services that will be supervised by S6: https://github.com/just-containers/s6-overlay#writing-a-service-script
7697
`/etc/services-available/` | same as above, but must be symlinked into `/etc/services.d/` to take effect
7798
`/run.d/` | shell scripts (ending in .sh) that make runtime modifications ahead of S6 initialization
99+
`/scripts` | convenience scripts that can be leveraged in derived images
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash -e
2+
3+
# --- Centos variant only, for other variants, see /scripts folder
4+
5+
#-------------------------------------------------------------------
6+
# Performs cleanup, ensure unnecessary packages and package lists
7+
# are safely removed, without triggering Docker AUFS permission bug
8+
#-------------------------------------------------------------------
9+
10+
yum clean all

container/root/clean.sh renamed to container/root/scripts/clean_ubuntu.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash -e
22

3+
# --- Ubuntu variant only, for other variants, see /scripts folder
4+
35
#-------------------------------------------------------------------
46
# Performs cleanup, ensure unnecessary packages and package lists
57
# are safely removed, without triggering Docker AUFS permission bug
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# --- Centos variant only, for other variants, see /scripts folder
4+
5+
#-------------------------------------------------------------------
6+
# Upgrade just the packages listed as security, without affecting
7+
# any subsequent usages of yum
8+
#-------------------------------------------------------------------
9+
10+
yum -y update --security

container/root/security_updates.sh renamed to container/root/scripts/security_updates_ubuntu.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
# --- Ubuntu variant only, for other variants, see /scripts folder
4+
35
#-------------------------------------------------------------------
46
# Upgrade just the packages listed as security, without affecting
57
# any subsequent usages of apt-get

docker-compose.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ubuntu:
44
- '8080:8080'
55
environment:
66
SERVER_LOG_MINIMAL: 1
7-
SERVER_APP_NAME: docker-test
7+
SERVER_APP_NAME: docker-test-ubuntu
88
S6_KILL_FINISH_MAXTIME: 1
99
S6_KILL_GRACETIME: 1
1010
alpine:
@@ -14,6 +14,16 @@ alpine:
1414
- '8081:8080'
1515
environment:
1616
SERVER_LOG_MINIMAL: 1
17-
SERVER_APP_NAME: docker-test
17+
SERVER_APP_NAME: docker-test-alpine
18+
S6_KILL_FINISH_MAXTIME: 1
19+
S6_KILL_GRACETIME: 1
20+
centos:
21+
build: .
22+
dockerfile: Dockerfile-centos
23+
ports:
24+
- '8082:8080'
25+
environment:
26+
SERVER_LOG_MINIMAL: 1
27+
SERVER_APP_NAME: docker-test-centos
1828
S6_KILL_FINISH_MAXTIME: 1
1929
S6_KILL_GRACETIME: 1

0 commit comments

Comments
 (0)