diff --git a/bitnami/openresty/1.21/debian-11/Dockerfile b/bitnami/openresty/1.21/debian-11/Dockerfile index 8833d267ffe1..ef17550d2576 100644 --- a/bitnami/openresty/1.21/debian-11/Dockerfile +++ b/bitnami/openresty/1.21/debian-11/Dockerfile @@ -3,10 +3,10 @@ FROM docker.io/bitnami/minideb:bullseye ARG TARGETARCH LABEL org.opencontainers.image.base.name="docker.io/bitnami/minideb:bullseye" \ - org.opencontainers.image.created="2023-02-23T22:31:04Z" \ + org.opencontainers.image.created="2023-02-24T17:48:33Z" \ org.opencontainers.image.description="Application packaged by VMware, Inc" \ org.opencontainers.image.licenses="Apache-2.0" \ - org.opencontainers.image.ref.name="1.21.4-1-debian-11-r92" \ + org.opencontainers.image.ref.name="1.21.4-1-debian-11-r93" \ org.opencontainers.image.title="openresty" \ org.opencontainers.image.vendor="VMware, Inc." \ org.opencontainers.image.version="1.21.4-1" @@ -22,7 +22,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] RUN install_packages ca-certificates curl libbrotli1 libbsd0 libcrypt1 libdeflate0 libexpat1 libfontconfig1 libfreetype6 libgcc-s1 libgcrypt20 libgd3 libgeoip1 libgpg-error0 libicu67 libjbig0 libjpeg62-turbo liblzma5 libmd0 libpcre3 libpng16-16 libssl1.1 libstdc++6 libtiff5 libuuid1 libwebp6 libx11-6 libxau6 libxcb1 libxdmcp6 libxml2 libxpm4 libxslt1.1 libzstd1 perl procps zlib1g RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \ COMPONENTS=( \ - "openresty-1.21.4-1-158-linux-${OS_ARCH}-debian-11" \ + "openresty-1.21.4-1-159-linux-${OS_ARCH}-debian-11" \ "gosu-1.16.0-2-linux-${OS_ARCH}-debian-11" \ ) && \ for COMPONENT in "${COMPONENTS[@]}"; do \ diff --git a/bitnami/openresty/1.21/debian-11/prebuildfs/opt/bitnami/.bitnami_components.json b/bitnami/openresty/1.21/debian-11/prebuildfs/opt/bitnami/.bitnami_components.json index 087627481a62..882c38d4b6a8 100644 --- a/bitnami/openresty/1.21/debian-11/prebuildfs/opt/bitnami/.bitnami_components.json +++ b/bitnami/openresty/1.21/debian-11/prebuildfs/opt/bitnami/.bitnami_components.json @@ -8,9 +8,9 @@ }, "openresty": { "arch": "amd64", - "digest": "4587fddc7fd6e01cae8536547ae15545f556e42501e462fa704b806eee3c2dec", + "digest": "f4530e1a6f726fe9691685638dc161b0ba87067fdae0ec73437e3a68b1a5532c", "distro": "debian-11", "type": "NAMI", - "version": "1.21.4-1-158" + "version": "1.21.4-1-159" } } \ No newline at end of file diff --git a/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/libopenresty.sh b/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/libopenresty.sh index 191cff2028e5..26e194f47198 100644 --- a/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/libopenresty.sh +++ b/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/libopenresty.sh @@ -2,7 +2,7 @@ # # Bitnami OpenResty library -# shellcheck disable=SC1091 +# shellcheck disable=SC1090,SC1091 # Load Generic Libraries . /opt/bitnami/scripts/libfs.sh @@ -156,3 +156,34 @@ openresty_initialize() { openresty_configure_port "$OPENRESTY_HTTP_PORT_NUMBER" fi } + +######################## +# Run custom initialization scripts +# Globals: +# OPENRESTY_* +# Arguments: +# None +# Returns: +# None +######################### +openresty_custom_init_scripts() { + info "Loading custom scripts..." + if [[ -d "$OPENRESTY_INITSCRIPTS_DIR" ]] && [[ -n $(find "$OPENRESTY_INITSCRIPTS_DIR/" -type f -regex ".*\.sh") ]] && [[ ! -f "$OPENRESTY_VOLUME_DIR/.user_scripts_initialized" || "$OPENRESTY_FORCE_INITSCRIPTS" == "true" ]]; then + info "Loading user's custom files from $OPENRESTY_INITSCRIPTS_DIR ..." + find "$OPENRESTY_INITSCRIPTS_DIR/" -type f -regex ".*\.sh" | sort | while read -r f; do + case "$f" in + *.sh) + if [[ -x "$f" ]]; then + debug "Executing $f" + "$f" + else + debug "Sourcing $f" + . "$f" + fi + ;; + *) debug "Ignoring $f" ;; + esac + done + touch "$OPENRESTY_VOLUME_DIR"/.user_scripts_initialized + fi +} diff --git a/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty-env.sh b/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty-env.sh index c241511df66c..8efd4ab9f009 100644 --- a/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty-env.sh +++ b/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty-env.sh @@ -24,6 +24,7 @@ export BITNAMI_DEBUG="${BITNAMI_DEBUG:-false}" openresty_env_vars=( OPENRESTY_HTTP_PORT_NUMBER OPENRESTY_HTTPS_PORT_NUMBER + OPENRESTY_FORCE_INITSCRIPTS ) for env_var in "${openresty_env_vars[@]}"; do file_env_var="${env_var}_FILE" @@ -48,6 +49,7 @@ export OPENRESTY_TMP_DIR="${OPENRESTY_BASE_DIR}/nginx/tmp" export OPENRESTY_LOGS_DIR="${OPENRESTY_BASE_DIR}/nginx/logs" export OPENRESTY_SERVER_BLOCKS_DIR="${OPENRESTY_CONF_DIR}/nginx/server_blocks" export OPENRESTY_SITE_DIR="${OPENRESTY_BASE_DIR}/site" +export OPENRESTY_INITSCRIPTS_DIR="/docker-entrypoint-initdb.d" export OPM_BASE_DIR="/home/openresty" export OPENRESTY_CONF_FILE="${OPENRESTY_CONF_DIR}/nginx.conf" export OPENRESTY_PID_FILE="${OPENRESTY_TMP_DIR}/nginx.pid" @@ -62,5 +64,6 @@ export OPENRESTY_DEFAULT_HTTPS_PORT_NUMBER="8443" # only used at build time # OpenResty configuration export OPENRESTY_HTTP_PORT_NUMBER="${OPENRESTY_HTTP_PORT_NUMBER:-}" export OPENRESTY_HTTPS_PORT_NUMBER="${OPENRESTY_HTTPS_PORT_NUMBER:-}" +export OPENRESTY_FORCE_INITSCRIPTS="${OPENRESTY_FORCE_INITSCRIPTS:-false}" # Custom environment variables may be defined below diff --git a/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty/postunpack.sh b/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty/postunpack.sh index 682d0d12e4e0..15e4f626d637 100755 --- a/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty/postunpack.sh +++ b/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty/postunpack.sh @@ -42,6 +42,7 @@ declare -a writable_dirs=( "$OPENRESTY_LOGS_DIR" "$OPENRESTY_TMP_DIR" "$OPENRESTY_SITE_DIR" + "$OPENRESTY_INITSCRIPTS_DIR" "$OPM_BASE_DIR" ) for dir in "${writable_dirs[@]}"; do diff --git a/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty/setup.sh b/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty/setup.sh index a9cb23edc116..d590d056c1ab 100755 --- a/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty/setup.sh +++ b/bitnami/openresty/1.21/debian-11/rootfs/opt/bitnami/scripts/openresty/setup.sh @@ -27,5 +27,8 @@ am_i_root && ensure_user_exists "$OPENRESTY_DAEMON_USER" --group "$OPENRESTY_DAE # Fix logging issue when running as root ! am_i_root || chmod o+w "$(readlink /dev/stdout)" "$(readlink /dev/stderr)" +# Execute init scripts +openresty_custom_init_scripts + # Initialize OpenResty openresty_initialize diff --git a/bitnami/openresty/README.md b/bitnami/openresty/README.md index 68d28c0bb874..ed627d88ca4f 100644 --- a/bitnami/openresty/README.md +++ b/bitnami/openresty/README.md @@ -108,6 +108,12 @@ Access your web server in the browser by navigating to `http://localhost:9000`. ## Configuration +### Initializing a new instance + +When the container is executed for the first time, it will execute the files with extensions `.sh` located at `/docker-entrypoint-initdb.d`. + +In order to have your custom files inside the docker image you can mount them as a volume. + ### Adding custom server blocks The default `nginx.conf` includes server blocks placed in `/opt/bitnami/openresty/nginx/conf/server_blocks/`. You can mount a `my_server_block.conf` file containing your custom server block at this location. @@ -235,6 +241,8 @@ FROM bitnami/openresty:latest RUN opm get openresty/lua-resty-lock ``` +Additionally, you can install your custom Lua modules using [your custom init scripts](#initializing-a-new-instance). + ## Reverse proxy to other containers OpenResty can be used to reverse proxy to other containers using Docker's linking system. This is particularly useful if you want to serve dynamic content through an OpenResty frontend. To do so, [add a server block](#adding-custom-server-blocks) like the following in the `/opt/bitnami/openresty/nginx/conf/server_blocks/` folder: @@ -286,6 +294,7 @@ The Bitnami OpenResty Docker image is designed to be extended so it can be used Before extending this image, please note there are certain configuration settings you can modify using the original image: * Settings that can be adapted using environment variables. For instance, you can change the port used by OpenResty for HTTP setting the environment variable `OPENRESTY_HTTP_PORT_NUMBER`. +* [Initializing a new instance](#initializing-a-new-instance) * [Adding custom server blocks](#adding-custom-server-blocks). * [Replacing the 'nginx.conf' file](#full-configuration). * [Using custom SSL certificates](#using-custom-ssl-certificates).