Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vaijab committed Jul 7, 2016
1 parent 4305f46 commit 6a7315b
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
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"]
56 changes: 56 additions & 0 deletions README.md
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
16 changes: 16 additions & 0 deletions bin/run.sh
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

0 comments on commit 6a7315b

Please sign in to comment.