Skip to content

Commit

Permalink
add envsubst to most images (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
neomantra committed Sep 6, 2017
1 parent 08e8840 commit 64186bf
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelog

## [Unreleased]

* Add `envsubst` utility
* Add `RESTY_CONFIG_OPTIONS_MORE` build-arg to facilitate adding options (versus overriding them)
* Use `CMD` instead of `ENTRYPOINT`

Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Table of Contents
* [Usage](#usage)
* [OPM](#opm)
* [LuaRocks](#luarocks)
* [Pitfalls](#pitfalls)
* [Tips & Pitfalls](#tips--pitfalls)
* [Docker CMD](#docker-entrypoint)
* [Building (from source)](#building-from-source)
* [Building (RPM based)](#building-rpm-based)
Expand Down Expand Up @@ -113,8 +113,11 @@ RUN /usr/local/openresty/luajit/bin/luarocks install <rock>
```


Pitfalls
========
Tips & Pitfalls
===============

* The `envsubst` utility is included in all images except `alpine`; this utility is also included
in the Nginx docker image and is used to template environment variables into configuration files.

* **Docker Hub** does not currently support ARM builds, thus the `armhf-xenial` image is not available. (See [#26](https://github.com/openresty/docker-openresty/pull/26))

Expand All @@ -127,12 +130,14 @@ docker build -f xenial/Dockerfile --build-arg "RESTY_CONFIG_OPTIONS_MORE=--with-
Docker CMD
==========

The `-g "daemon off;"` directive is used in the Dockerfile CMD to keep the Nginx daemon running after container creation. If this directive is added to the nginx.conf, then it may be omitted from the CMD.

To invoke with another CMD, for example the `resty` utility, invoke like so:
The `-g "daemon off;"` directive is used in the Dockerfile CMD to keep the Nginx daemon running after container creation. If this directive is added to the nginx.conf, then the `docker run` should explicitly invoke `openresty`:
```
docker run [options] openresty/openresty:xenial openresty
```

Invoke another CMD, for example the `resty` utility, like so:
```
docker run [options] openresty/openresty:xenial /usr/local/openresty/bin/resty [script.lua]
docker run [options] openresty/openresty:xenial resty [script.lua]
```

*NOTE* The `alpine` images do not include the packages `perl` and `ncurses`, which is needed by the `resty` utility.
Expand Down
16 changes: 13 additions & 3 deletions alpine-fat/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ ARG _RESTY_CONFIG_DEPS="--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} --w
# 3) Build OpenResty
# 4) Cleanup

RUN \
apk add --no-cache --virtual .build-deps \
RUN apk add --no-cache --virtual .build-deps \
curl \
gd-dev \
geoip-dev \
Expand Down Expand Up @@ -105,7 +104,18 @@ RUN \
&& make install \
&& cd /tmp \
&& rm -rf luarocks-${RESTY_LUAROCKS_VERSION} luarocks-${RESTY_LUAROCKS_VERSION}.tar.gz \
&& apk del .build-deps \
&& apk add --no-cache --virtual .gettext gettext \
&& mv /usr/bin/envsubst /tmp/ \
&& runDeps="$( \
scanelf --needed --nobanner /tmp/envsubst \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache --virtual $runDeps \
&& apk del .build-deps .gettext \
&& mv /tmp/envsubst /usr/local/bin/ \
&& ln -sf /dev/stdout /usr/local/openresty/nginx/logs/access.log \
&& ln -sf /dev/stderr /usr/local/openresty/nginx/logs/error.log

Expand Down
3 changes: 1 addition & 2 deletions alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ ARG _RESTY_CONFIG_DEPS="--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} --w
# 3) Build OpenResty
# 4) Cleanup

RUN \
apk add --no-cache --virtual .build-deps \
RUN apk add --no-cache --virtual .build-deps \
build-base \
curl \
gd-dev \
Expand Down
4 changes: 2 additions & 2 deletions armhf-xenial/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ ARG _RESTY_CONFIG_DEPS="--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} --w
# 3) Build OpenResty
# 4) Cleanup

RUN \
DEBIAN_FRONTEND=noninteractive apt-get update \
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
gettext-base \
libgd-dev \
libgeoip-dev \
libncurses5-dev \
Expand Down
4 changes: 2 additions & 2 deletions centos-rpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ARG RESTY_RPM_FLAVOR=""
ARG RESTY_RPM_VERSION="1.11.2.5-1.el7.centos"
ARG RESTY_RPM_ARCH="x86_64"

RUN yum install -y yum-utils \
&& yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo \
RUN yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo \
&& yum install -y \
gettext \
make \
openresty${RESTY_RPM_FLAVOR}-${RESTY_RPM_VERSION}.${RESTY_RPM_ARCH} \
openresty-opm-${RESTY_RPM_VERSION} \
Expand Down
4 changes: 2 additions & 2 deletions centos/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ ARG _RESTY_CONFIG_DEPS="--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} --w
# 3) Build OpenResty
# 4) Cleanup

RUN \
yum install -y \
RUN yum install -y \
gcc \
gcc-c++ \
gd-devel \
gettext \
GeoIP-devel \
libxslt-devel \
make \
Expand Down
4 changes: 2 additions & 2 deletions jessie/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ ARG _RESTY_CONFIG_DEPS="--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} --w
# 3) Build OpenResty
# 4) Cleanup

RUN \
DEBIAN_FRONTEND=noninteractive apt-get update \
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
gettext-base \
libgd-dev \
libgeoip-dev \
libncurses5-dev \
Expand Down
1 change: 1 addition & 0 deletions stretch/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ARG RESTY_DEB_FLAVOR=""
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
gettext-base \
gnupg2 \
lsb-release \
software-properties-common \
Expand Down
4 changes: 2 additions & 2 deletions trusty/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ ARG _RESTY_CONFIG_DEPS="--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} --w
# 3) Build OpenResty
# 4) Cleanup

RUN \
DEBIAN_FRONTEND=noninteractive apt-get update \
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
gettext-base \
libgd-dev \
libgeoip-dev \
libncurses5-dev \
Expand Down
4 changes: 2 additions & 2 deletions wheezy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ ARG _RESTY_CONFIG_DEPS="--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} --w
# 3) Build OpenResty
# 4) Cleanup

RUN \
DEBIAN_FRONTEND=noninteractive apt-get update \
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
gettext-base \
libgd2-noxpm-dev \
libgeoip-dev \
libncurses5-dev \
Expand Down
4 changes: 2 additions & 2 deletions xenial/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ ARG _RESTY_CONFIG_DEPS="--with-openssl=/tmp/openssl-${RESTY_OPENSSL_VERSION} --w
# 3) Build OpenResty
# 4) Cleanup

RUN \
DEBIAN_FRONTEND=noninteractive apt-get update \
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
gettext-base \
libgd-dev \
libgeoip-dev \
libncurses5-dev \
Expand Down

0 comments on commit 64186bf

Please sign in to comment.