Skip to content

Commit 57d338c

Browse files
author
Wojciech Międzybrodzki
committed
chore: openresty with envsubst in entrypoint
1 parent faabdd0 commit 57d338c

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

.ops/openresty/Dockerfile

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# syntax=docker/dockerfile:1.11.1
2+
FROM openresty/openresty:1.21.4.1-0-jammy
3+
4+
# Openresty with nginx entrypoint (envsubst)
5+
6+
COPY --from=nginx:stable-bookworm /docker-entrypoint.d /docker-entrypoint.d
7+
COPY ./.ops/openresty/docker-entrypoint.sh /docker-entrypoint.sh
8+
ENTRYPOINT ["/docker-entrypoint.sh"]
9+
CMD ["/usr/local/openresty/bin/openresty", "-g", "daemon off;"]

.ops/openresty/docker-entrypoint.sh

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/sh
2+
# vim:sw=4:ts=4:et
3+
4+
set -e
5+
6+
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
7+
exec 3>&1
8+
else
9+
exec 3>/dev/null
10+
fi
11+
12+
if [ "$1" = "/usr/local/openresty/bin/openresty" ]; then
13+
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
14+
echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
15+
16+
echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/"
17+
find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do
18+
case "$f" in
19+
*.sh)
20+
if [ -x "$f" ]; then
21+
echo >&3 "$0: Launching $f";
22+
"$f"
23+
else
24+
# warn on shell scripts without exec bit
25+
echo >&3 "$0: Ignoring $f, not executable";
26+
fi
27+
;;
28+
*) echo >&3 "$0: Ignoring $f";;
29+
esac
30+
done
31+
32+
echo >&3 "$0: Configuration complete; ready for start up"
33+
else
34+
echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration"
35+
fi
36+
fi
37+
38+
exec "$@"

docker-compose.yaml

+19
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ services:
2222
- ./vendor:/app/vendor
2323
- ./src:/app/src
2424

25+
openresty:
26+
build:
27+
dockerfile: ./.ops/openresty/Dockerfile
28+
context: .
29+
tags:
30+
- "ghcr.io/wojciechem/openresty:dev-local"
31+
ports:
32+
- target: 80
33+
published: 8700
34+
protocol: tcp
35+
volumes:
36+
- ./.ops/server.conf.template:/etc/nginx/templates/default.conf.template/:ro
37+
- ./public:/app/public
38+
environment:
39+
- NGINX_HOST=localhost
40+
- REDIRECT_DOMAIN=localhost:8700
41+
- APP_HOST=webapp
42+
- APP_PORT=9000
43+
2544
nginx:
2645
image: nginx:1.25.1
2746
ports:

0 commit comments

Comments
 (0)