Skip to content

Commit 46167d6

Browse files
authored
Merge pull request #39 from bryanlatten/feature-base
Dockerfile: now sync’d from behance/docker-base
2 parents b8f6756 + b15b56c commit 46167d6

File tree

7 files changed

+31
-52
lines changed

7 files changed

+31
-52
lines changed

Dockerfile

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1-
FROM ubuntu:14.04
1+
FROM behance/docker-base:1.3
22
MAINTAINER Bryan Latten <[email protected]>
33

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-
CONTAINER_ROLE=web \
4+
ENV CONTAINER_ROLE=web \
85
CONTAINER_PORT=8080 \
96
CONF_NGINX_SITE="/etc/nginx/sites-available/default" \
107
CONF_NGINX_SERVER="/etc/nginx/nginx.conf" \
11-
NOT_ROOT_USER=www-data \
12-
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
13-
S6_KILL_FINISH_MAXTIME=5000 \
14-
S6_KILL_GRACETIME=3000
8+
NOT_ROOT_USER=www-data
9+
10+
# Using a non-privileged port to prevent having to use setcap internally
11+
EXPOSE ${CONTAINER_PORT}
1512

1613
# Ensure base system is up to date
1714
RUN apt-get update && \
1815
apt-get upgrade -yqq && \
1916
# Install pre-reqs \
2017
apt-get install -yqq \
2118
software-properties-common \
22-
curl \
2319
&& \
24-
# Add goss for local testing
25-
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.2.3/goss-linux-amd64 -o /usr/local/bin/goss && \
26-
chmod +x /usr/local/bin/goss && \
27-
apt-get remove --purge -yq curl && \
2820
# Install latest nginx (development PPA is actually mainline development) \
2921
add-apt-repository ppa:nginx/development -y && \
3022
apt-get update -yqq && \
@@ -39,27 +31,24 @@ RUN apt-get update && \
3931
make \
4032
unattended-upgrades \
4133
python* \
42-
&& \
34+
&& \
4335
apt-get autoclean -y && \
4436
apt-get autoremove -y && \
4537
rm -rf /var/lib/{cache,log}/ && \
46-
rm -rf /var/lib/apt/lists/ && \
47-
rm -rf /tmp/* /var/tmp/*
38+
rm -rf /tmp/* /var/tmp/* && \
39+
rm -rf /var/lib/apt/lists/*.lz4
4840

4941
# Overlay the root filesystem from this repo
5042
COPY ./container/root /
5143

52-
# Add S6 overlay build, to avoid having to build from source
53-
RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C / && \
54-
rm /tmp/s6-overlay-amd64.tar.gz && \
55-
# Set nginx to listen on defined port \
56-
sed -i "s/listen [0-9]*;/listen ${CONTAINER_PORT};/" $CONF_NGINX_SITE
44+
# Set nginx to listen on defined port
45+
# NOTE: order of operations is important, new config had to already installed from repo (above)
46+
RUN sed -i "s/listen [0-9]*;/listen ${CONTAINER_PORT};/" $CONF_NGINX_SITE && \
47+
# Make temp directory for .nginx runtime files \
48+
mkdir /tmp/.nginx
5749

58-
RUN goss -g goss.nginx.yaml validate && \
59-
/tmp/aufs_hack.sh
60-
61-
# Using a non-privileged port to prevent having to use setcap internally
62-
EXPOSE ${CONTAINER_PORT}
50+
RUN goss -g /tests/nginx/base.goss.yaml validate && \
51+
/aufs_hack.sh
6352

6453
# NOTE: intentionally NOT using s6 init as the entrypoint
6554
# This would prevent container debugging if any of those service crash

Dockerfile-alpine

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
FROM alpine:3.4
1+
FROM behance/docker-base:1.3-alpine
22
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
6-
ENV SIGNAL_BUILD_STOP=99 \
7-
CONTAINER_ROLE=web \
6+
ENV CONTAINER_ROLE=web \
87
CONTAINER_PORT=8080 \
98
CONF_NGINX_SITE="/etc/nginx/sites-available/default" \
109
CONF_NGINX_SERVER="/etc/nginx/nginx.conf" \
11-
NOT_ROOT_USER=www-data \
12-
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
13-
S6_KILL_FINISH_MAXTIME=5000 \
14-
S6_KILL_GRACETIME=3000
10+
NOT_ROOT_USER=www-data
11+
12+
# Using a non-privileged port to prevent having to use setcap internally
13+
EXPOSE ${CONTAINER_PORT}
1514

1615
# Create an unprivileged user
1716
RUN adduser -D -S -H $NOT_ROOT_USER
@@ -22,30 +21,22 @@ RUN apk update && \
2221
bash \
2322
grep \
2423
nginx \
25-
curl \
2624
&& \
27-
curl -L https://github.com/aelsabbahy/goss/releases/download/v0.2.3/goss-linux-amd64 -o /usr/local/bin/goss && \
28-
chmod +x /usr/local/bin/goss && \
29-
apk del curl && \
3025
rm -rf /var/cache/apk/*
3126

3227
# Overlay the root filesystem from this repo
3328
COPY ./container/root /
3429

35-
# Add S6 overlay build, to avoid having to build from source
36-
RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C / && \
37-
rm /tmp/s6-overlay-amd64.tar.gz && \
38-
# Set nginx to listen on defined port \
39-
sed -i "s/listen [0-9]*;/listen ${CONTAINER_PORT};/" $CONF_NGINX_SITE && \
30+
# Set nginx to listen on defined port \
31+
RUN sed -i "s/listen [0-9]*;/listen ${CONTAINER_PORT};/" $CONF_NGINX_SITE && \
4032
# Fix permissions to run unprivileged
4133
bash -c "chown www-data:www-data /var/{lib,log}/nginx -Rh" && \
42-
bash -c "chmod 0755 -R /var/{lib,log}/nginx"
34+
bash -c "chmod 0755 -R /var/{lib,log}/nginx" && \
35+
# Make temp directory for .nginx runtime files \
36+
mkdir /tmp/.nginx
4337

44-
RUN goss -g goss.nginx.yaml validate && \
45-
/tmp/aufs_hack.sh
46-
47-
# Using a non-privileged port to prevent having to use setcap internally
48-
EXPOSE ${CONTAINER_PORT}
38+
RUN goss -g /tests/nginx/base.goss.yaml validate && \
39+
/aufs_hack.sh
4940

5041
# NOTE: intentionally NOT using s6 init as the entrypoint
5142
# This would prevent container debugging if any of those service crash
File renamed without changes.
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Shouldn't need to be two separate statements, something is requiring it
21
/tmp/.nginx true www-data 0644 2700
32
/tmp true www-data 0644 2700
4-
5-
# Unfortunately, even if it isn't used, it gets a lock by nginx
63
/var/log/nginx/error.log true www-data 0644 2700

container/root/goss.nginx.yaml renamed to container/root/tests/nginx/base.goss.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
gossfile:
2+
../../goss.base.yaml: {}
13
group:
24
www-data:
35
exists: true

container/root/tmp/.nginx/.gitkeep

Whitespace-only changes.
-905 KB
Binary file not shown.

0 commit comments

Comments
 (0)