-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from bryanlatten/feature-alpine
Dockerfile: optional move to alpine
- Loading branch information
Showing
6 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
FROM alpine:3.4 | ||
MAINTAINER Bryan Latten <[email protected]> | ||
|
||
# Use in multi-phase builds, when an init process requests for the container to gracefully exit, so that it may be committed | ||
# Used with alternative CMD (worker.sh), leverages supervisor to maintain long-running processes | ||
ENV SIGNAL_BUILD_STOP=99 \ | ||
CONTAINER_ROLE=web \ | ||
CONTAINER_PORT=8080 \ | ||
CONF_NGINX_SITE="/etc/nginx/sites-available/default" \ | ||
CONF_NGINX_SERVER="/etc/nginx/nginx.conf" \ | ||
NOT_ROOT_USER=www-data \ | ||
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \ | ||
S6_KILL_FINISH_MAXTIME=5000 \ | ||
S6_KILL_GRACETIME=3000 | ||
|
||
# Create an unprivileged user | ||
RUN adduser -D -S -H $NOT_ROOT_USER | ||
|
||
RUN apk update && \ | ||
apk add \ | ||
sed \ | ||
bash \ | ||
grep \ | ||
nginx \ | ||
&& \ | ||
rm -rf /var/cache/apk/* | ||
|
||
# Overlay the root filesystem from this repo | ||
COPY ./container/root / | ||
|
||
# Add S6 overlay build, to avoid having to build from source | ||
RUN tar xzf /tmp/s6-overlay-amd64.tar.gz -C / && \ | ||
rm /tmp/s6-overlay-amd64.tar.gz && \ | ||
# Set nginx to listen on defined port \ | ||
sed -i "s/listen [0-9]*;/listen ${CONTAINER_PORT};/" $CONF_NGINX_SITE && \ | ||
# Fix permissions to run unprivileged | ||
bash -c "chown www-data:www-data /var/{lib,log}/nginx -Rh" && \ | ||
bash -c "chmod 0755 -R /var/{lib,log}/nginx" | ||
|
||
|
||
# Using a non-privileged port to prevent having to use setcap internally | ||
EXPOSE ${CONTAINER_PORT} | ||
|
||
# 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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Welcome to nginx!</title> | ||
<style> | ||
body { | ||
width: 35em; | ||
margin: 0 auto; | ||
font-family: Tahoma, Verdana, Arial, sans-serif; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Welcome to nginx!</h1> | ||
<p>If you see this page, the nginx web server is successfully installed and | ||
working. Further configuration is required.</p> | ||
|
||
<p>For online documentation and support please refer to | ||
<a href="http://nginx.org/">nginx.org</a>.<br/> | ||
Commercial support is available at | ||
<a href="http://nginx.com/">nginx.com</a>.</p> | ||
|
||
<p><em>Thank you for using nginx.</em></p> | ||
</body> | ||
</html> | ||
|
||
|
||
<h1>It Works!</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
ubuntu: | ||
build: . | ||
ports: | ||
- '8080:8080' | ||
environment: | ||
SERVER_LOG_MINIMAL: 1 | ||
SERVER_APP_NAME: docker-test | ||
S6_KILL_FINISH_MAXTIME: 1 | ||
S6_KILL_GRACETIME: 1 | ||
alpine: | ||
build: . | ||
dockerfile: Dockerfile-alpine | ||
ports: | ||
- '8081:8080' | ||
environment: | ||
SERVER_LOG_MINIMAL: 1 | ||
SERVER_APP_NAME: docker-test | ||
S6_KILL_FINISH_MAXTIME: 1 | ||
S6_KILL_GRACETIME: 1 |