Add jq to Docker image and improve UNIT_SOURCE handling
- Include jq in the Docker image for JSON processing. - Refactor UNIT_SOURCE logic to cleanly update configuration using jq. - Remove obsolete UNIT_SOURCE handling code.
This commit is contained in:
@@ -19,7 +19,7 @@ COPY --from=unit_builder /var/lib/unit/ /var/lib/unit/
|
||||
|
||||
COPY docker/unit-config.json /docker-entrypoint.d/config.json
|
||||
|
||||
RUN apk --no-cache add pcre2 libbz2 libpng libwebp libjpeg-turbo icu-libs freetype oniguruma libzip \
|
||||
RUN apk --no-cache add pcre2 libbz2 libpng libwebp libjpeg-turbo icu-libs freetype oniguruma libzip jq \
|
||||
&& apk add --no-cache --virtual .phpize-deps icu-dev libpng-dev bzip2-dev libwebp-dev libjpeg-turbo-dev freetype-dev oniguruma-dev libzip-dev pcre2-dev ${PHPIZE_DEPS} \
|
||||
&& docker-php-ext-configure intl --enable-intl && \
|
||||
docker-php-ext-configure bcmath --enable-bcmath && \
|
||||
|
@@ -42,6 +42,20 @@ if [ "$role" = "app" ]; then
|
||||
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then
|
||||
echo "$0: /docker-entrypoint.d/ is not empty, applying initial configuration..."
|
||||
|
||||
if [[ -n "${UNIT_SOURCE:-}" ]]; then
|
||||
config="/docker-entrypoint.d/config.json"
|
||||
tmp="$(mktemp)"
|
||||
jq --arg src "${UNIT_SOURCE}" '
|
||||
.listeners["*:9000"].forwarded.source =
|
||||
( $src
|
||||
| split(",")
|
||||
| map( gsub("^\\s+|\\s+$"; "") ) # trim пробелы
|
||||
| map( select(. != "") ) # убрать пустые
|
||||
)
|
||||
' "$config" > "$tmp"
|
||||
mv "$tmp" "$config"
|
||||
fi
|
||||
|
||||
echo "$0: Looking for certificate bundles in /docker-entrypoint.d/..."
|
||||
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.pem"); do
|
||||
echo "$0: Uploading certificates bundle: $f"
|
||||
@@ -60,12 +74,6 @@ if [ "$role" = "app" ]; then
|
||||
curl_put $f "config"
|
||||
done
|
||||
|
||||
if [ ! -z ${UNIT_SOURCE+x} ]
|
||||
then
|
||||
echo $UNIT_SOURCE > /docker-entrypoint.d/unit_source.json
|
||||
curl_put "/docker-entrypoint.d/unit_source.json" "config/listeners/*:9000/forwarded/source"
|
||||
fi
|
||||
|
||||
echo "$0: Looking for shell scripts in /docker-entrypoint.d/..."
|
||||
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh"); do
|
||||
echo "$0: Launching $f";
|
||||
|
@@ -42,6 +42,20 @@ if [ "$role" = "app" ]; then
|
||||
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -print -quit 2>/dev/null | /bin/grep -q .; then
|
||||
echo "$0: /docker-entrypoint.d/ is not empty, applying initial configuration..."
|
||||
|
||||
if [[ -n "${UNIT_SOURCE:-}" ]]; then
|
||||
config="/docker-entrypoint.d/config.json"
|
||||
tmp="$(mktemp)"
|
||||
jq --arg src "${UNIT_SOURCE}" '
|
||||
.listeners["*:9000"].forwarded.source =
|
||||
( $src
|
||||
| split(",")
|
||||
| map( gsub("^\\s+|\\s+$"; "") ) # trim пробелы
|
||||
| map( select(. != "") ) # убрать пустые
|
||||
)
|
||||
' "$config" > "$tmp"
|
||||
mv "$tmp" "$config"
|
||||
fi
|
||||
|
||||
echo "$0: Looking for certificate bundles in /docker-entrypoint.d/..."
|
||||
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.pem"); do
|
||||
echo "$0: Uploading certificates bundle: $f"
|
||||
@@ -60,12 +74,6 @@ if [ "$role" = "app" ]; then
|
||||
curl_put $f "config"
|
||||
done
|
||||
|
||||
if [ ! -z ${UNIT_SOURCE+x} ]
|
||||
then
|
||||
echo $UNIT_SOURCE > /docker-entrypoint.d/unit_source.json
|
||||
curl_put "/docker-entrypoint.d/unit_source.json" "config/listeners/*:9000/forwarded/source"
|
||||
fi
|
||||
|
||||
echo "$0: Looking for shell scripts in /docker-entrypoint.d/..."
|
||||
for f in $(/usr/bin/find /docker-entrypoint.d/ -type f -name "*.sh"); do
|
||||
echo "$0: Launching $f";
|
||||
|
Reference in New Issue
Block a user