-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
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,8 @@ | ||
FROM alpine:3.4 | ||
|
||
RUN apk upgrade --no-cache | ||
RUN apk add --no-cache nginx bash | ||
|
||
ADD bin/run.sh /run.sh | ||
|
||
ENTRYPOINT ["/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,58 @@ | ||
# docker-nginx | ||
Minimal bare nginx docker image | ||
|
||
|
||
### Configuration | ||
There are two ways to pass nginx configuration. | ||
|
||
#### Config block via env variable | ||
Read in a config block preserving new lines, etc. | ||
|
||
``` | ||
read -r -d '' NGINX_CONFIG <<'EOF' | ||
user nginx; | ||
worker_processes auto; | ||
error_log /dev/stderr error; | ||
events { | ||
worker_connections 1024; | ||
} | ||
http { | ||
sendfile on; | ||
tcp_nopush on; | ||
tcp_nodelay on; | ||
keepalive_timeout 65; | ||
types_hash_max_size 2048; | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
server { | ||
listen 80 default_server; | ||
server_name _; | ||
location / { | ||
return 200 "Everything is OK.\n"; | ||
} | ||
} | ||
} | ||
EOF | ||
``` | ||
|
||
``` | ||
export NGINX_CONFIG | ||
docker run -ti --rm -e NGINX_CONFIG quay.io/ukhomeofficedigital/nginx:v0.0.1 | ||
``` | ||
|
||
#### Config file via env variable | ||
You can provide a config file inside a container instead. | ||
|
||
``` | ||
docker run -ti --rm -e NGINX_CONFIG_FILE=/config/nginx.conf quay.io/ukhomeofficedigital/nginx:v0.0.1 | ||
``` | ||
|
||
|
||
### Extra Configs | ||
|
||
TODO |
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,16 @@ | ||
#!/bin/bash - | ||
|
||
set -o errexit | ||
|
||
mkdir -p /run/nginx | ||
|
||
# config file takes precedence | ||
if [[ -f ${NGINX_CONFIG_FILE} ]]; then | ||
nginx -g 'daemon off;' -c ${NGINX_CONFIG_FILE} | ||
elif [[ -n ${NGINX_CONFIG} ]]; then | ||
cp <(echo "${NGINX_CONFIG}") /etc/nginx/nginx.conf | ||
nginx -g 'daemon off;' -c /etc/nginx/nginx.conf | ||
else | ||
echo "[error] please set NGINX_CONFIG_FILE or NGINX_CONFIG variable." | ||
exit 1 | ||
fi |