mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
more clanup
This commit is contained in:
parent
ce34e4d046
commit
f2c8497136
5 changed files with 100 additions and 75 deletions
|
@ -126,9 +126,9 @@ RUN --mount=type=cache,id=pixelfed-apt-${PHP_VERSION}-${PHP_DEBIAN_RELEASE}-${TA
|
|||
|
||||
FROM base AS php-extensions
|
||||
|
||||
ARG PHP_EXTENSIONS_DATABASE
|
||||
ARG PHP_DEBIAN_RELEASE
|
||||
ARG PHP_EXTENSIONS
|
||||
ARG PHP_EXTENSIONS_DATABASE
|
||||
ARG PHP_EXTENSIONS_EXTRA
|
||||
ARG PHP_PECL_EXTENSIONS
|
||||
ARG PHP_PECL_EXTENSIONS_EXTRA
|
||||
|
@ -136,13 +136,10 @@ ARG PHP_VERSION
|
|||
ARG TARGETPLATFORM
|
||||
|
||||
ENV PHP_EXTENSIONS_DATABASE=${PHP_EXTENSIONS_DATABASE}
|
||||
ENV PHP_DEBIAN_RELEASE=${PHP_DEBIAN_RELEASE}
|
||||
ENV PHP_EXTENSIONS_EXTRA=${PHP_EXTENSIONS_EXTRA}
|
||||
ENV PHP_EXTENSIONS=${PHP_EXTENSIONS}
|
||||
ENV PHP_PECL_EXTENSIONS_EXTRA=${PHP_PECL_EXTENSIONS_EXTRA}
|
||||
ENV PHP_PECL_EXTENSIONS=${PHP_PECL_EXTENSIONS}
|
||||
ENV PHP_VERSION=${PHP_VERSION}
|
||||
ENV TARGETPLATFORM=${TARGETPLATFORM}
|
||||
|
||||
COPY contrib/docker/shared/root/docker/install/php-extensions.sh /docker/install/php-extensions.sh
|
||||
RUN --mount=type=cache,id=pixelfed-php-${PHP_VERSION}-${PHP_DEBIAN_RELEASE}-${TARGETPLATFORM},sharing=locked,target=/usr/src/php/ \
|
||||
|
|
|
@ -2,20 +2,23 @@
|
|||
|
||||
# NOTE:
|
||||
#
|
||||
# this file is *sourced* not run by the entrypoint runner
|
||||
# This file is *sourced* not run by the entrypoint runner
|
||||
# so any environment values set here will be accessible to all sub-processes
|
||||
# and future entrypoint.d scripts
|
||||
#
|
||||
# We also don't need to source `helpers.sh` since it's already available
|
||||
|
||||
entrypoint-set-name "${BASH_SOURCE[0]}"
|
||||
|
||||
load-config-files
|
||||
|
||||
# We assign a 1MB buffer to the just-in-time calculated max post size to allow for fields and overhead
|
||||
: ${POST_MAX_SIZE_BUFFER:=1M}
|
||||
log-info "POST_MAX_SIZE_BUFFER is set to [${POST_MAX_SIZE_BUFFER}]"
|
||||
buffer=$(numfmt --invalid=fail --from=auto --to=none --to-unit=K "${POST_MAX_SIZE_BUFFER}")
|
||||
log-info "POST_MAX_SIZE_BUFFER converted to KB is [${buffer}]"
|
||||
|
||||
# Automatically calculate the [post_max_size] value for [php.ini] and [nginx]
|
||||
log-info "POST_MAX_SIZE will be calculated by [({MAX_PHOTO_SIZE} * {MAX_ALBUM_LENGTH}) + {POST_MAX_SIZE_BUFFER}]"
|
||||
log-info " MAX_PHOTO_SIZE=${MAX_PHOTO_SIZE}"
|
||||
log-info " MAX_ALBUM_LENGTH=${MAX_ALBUM_LENGTH}"
|
||||
|
@ -23,4 +26,5 @@ log-info " POST_MAX_SIZE_BUFFER=${buffer}"
|
|||
: ${POST_MAX_SIZE:=$(numfmt --invalid=fail --from=auto --from-unit=K --to=si $(((${MAX_PHOTO_SIZE} * ${MAX_ALBUM_LENGTH}) + ${buffer})))}
|
||||
log-info "POST_MAX_SIZE was calculated to [${POST_MAX_SIZE}]"
|
||||
|
||||
# NOTE: must export the value so it's available in other scripts!
|
||||
export POST_MAX_SIZE
|
||||
|
|
|
@ -3,37 +3,53 @@ source /docker/helpers.sh
|
|||
|
||||
entrypoint-set-name "$0"
|
||||
|
||||
declare template_dir="${ENVSUBST_TEMPLATE_DIR:-/docker/templates}"
|
||||
declare output_dir="${ENVSUBST_OUTPUT_DIR:-}"
|
||||
declare filter="${ENVSUBST_FILTER:-}"
|
||||
declare template defined_envs relative_path output_path output_dir subdir
|
||||
|
||||
# load all dot-env files
|
||||
load-config-files
|
||||
|
||||
# Show [git diff] of templates being rendered (will help verify output)
|
||||
: ${ENTRYPOINT_SHOW_TEMPLATE_DIFF:=1}
|
||||
# Directory where templates can be found
|
||||
: ${ENTRYPOINT_TEMPLATE_DIR:=/docker/templates/}
|
||||
# Root path to write template template_files to (default is '', meaning it will be written to /<path>)
|
||||
: ${ENTRYPOINT_TEMPLATE_OUTPUT_PREFIX:=}
|
||||
|
||||
declare template_file relative_template_file_path output_file_dir
|
||||
|
||||
# load all dot-env config files
|
||||
load-config-files
|
||||
|
||||
# export all dot-env variables so they are available in templating
|
||||
export ${seen_dot_env_variables[@]}
|
||||
|
||||
find "$template_dir" -follow -type f -print | while read -r template; do
|
||||
relative_path="${template#"$template_dir/"}"
|
||||
subdir=$(dirname "$relative_path")
|
||||
output_path="$output_dir/${relative_path}"
|
||||
output_dir=$(dirname "$output_path")
|
||||
find "${ENTRYPOINT_TEMPLATE_DIR}" -follow -type f -print | while read -r template_file; do
|
||||
# Example: template_file=/docker/templates/usr/local/etc/php/php.ini
|
||||
|
||||
if [ ! -w "$output_dir" ]; then
|
||||
log-error-and-exit "ERROR: $template_dir exists, but $output_dir is not writable"
|
||||
# The file path without the template dir prefix ($ENTRYPOINT_TEMPLATE_DIR)
|
||||
#
|
||||
# Example: /usr/local/etc/php/php.ini
|
||||
relative_template_file_path="${template_file#"${ENTRYPOINT_TEMPLATE_DIR}"}"
|
||||
|
||||
# Adds optional prefix to the output file path
|
||||
#
|
||||
# Example: /usr/local/etc/php/php.ini
|
||||
output_file_path="${ENTRYPOINT_TEMPLATE_OUTPUT_PREFIX}/${relative_template_file_path}"
|
||||
|
||||
# Remove the file from the path
|
||||
#
|
||||
# Example: /usr/local/etc/php
|
||||
output_file_dir=$(dirname "${output_file_path}")
|
||||
|
||||
# Ensure the output directory is writable
|
||||
if ! is-writable "${output_file_dir}"; then
|
||||
log-error-and-exit "${output_file_dir} is not writable"
|
||||
fi
|
||||
|
||||
# create a subdirectory where the template file exists
|
||||
mkdir -p "$output_dir/$subdir"
|
||||
# Create the output directory if it doesn't exists
|
||||
ensure-directory "${output_file_dir}"
|
||||
|
||||
log-info "Running [gomplate] on [$template] --> [$output_path]"
|
||||
cat "$template" | gomplate >"$output_path"
|
||||
# Render the template
|
||||
log-info "Running [gomplate] on [${template_file}] --> [${output_file_path}]"
|
||||
cat "${template_file}" | gomplate >"${output_file_path}"
|
||||
|
||||
# Show the diff from the envsubst command
|
||||
if [[ ${ENTRYPOINT_SHOW_TEMPLATE_DIFF} = 1 ]]; then
|
||||
git --no-pager diff "$template" "${output_path}" || :
|
||||
git --no-pager diff "${template_file}" "${output_file_path}" || :
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -1,29 +1,26 @@
|
|||
#!/bin/bash
|
||||
set -e -o errexit -o nounset -o pipefail
|
||||
if [[ ${ENTRYPOINT_SKIP:=0} != 0 ]]; then
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
: ${ENTRYPOINT_SKIP:=0}
|
||||
: ${ENTRYPOINT_SKIP_SCRIPTS:=""}
|
||||
: ${ENTRYPOINT_DEBUG:=0}
|
||||
: ${ENTRYPOINT_ROOT:="/docker/entrypoint.d/"}
|
||||
: ${ENTRYPOINT_SKIP_SCRIPTS:=""}
|
||||
|
||||
export ENTRYPOINT_ROOT
|
||||
|
||||
if [[ ${ENTRYPOINT_SKIP} == 0 ]]; then
|
||||
[[ ${ENTRYPOINT_DEBUG} == 1 ]] && set -x
|
||||
source /docker/helpers.sh
|
||||
|
||||
source /docker/helpers.sh
|
||||
entrypoint-set-name "entrypoint.sh"
|
||||
|
||||
entrypoint-set-name "entrypoint.sh"
|
||||
declare -a skip_scripts
|
||||
IFS=' ' read -a skip_scripts <<<"$ENTRYPOINT_SKIP_SCRIPTS"
|
||||
|
||||
declare -a skip_scripts
|
||||
IFS=' ' read -a skip_scripts <<<"$ENTRYPOINT_SKIP_SCRIPTS"
|
||||
declare script_name
|
||||
|
||||
declare script_name
|
||||
# ensure the entrypoint folder exists
|
||||
mkdir -p "${ENTRYPOINT_ROOT}"
|
||||
|
||||
# ensure the entrypoint folder exists
|
||||
mkdir -p "${ENTRYPOINT_ROOT}"
|
||||
|
||||
if /usr/bin/find "${ENTRYPOINT_ROOT}" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
|
||||
if /usr/bin/find "${ENTRYPOINT_ROOT}" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
|
||||
log-info "looking for shell scripts in /docker/entrypoint.d/"
|
||||
|
||||
find "${ENTRYPOINT_ROOT}" -follow -type f -print | sort -V | while read -r file; do
|
||||
|
@ -68,9 +65,8 @@ if [[ ${ENTRYPOINT_SKIP} == 0 ]]; then
|
|||
done
|
||||
|
||||
log-info "Configuration complete; ready for start up"
|
||||
else
|
||||
else
|
||||
log-warning "No files found in ${ENTRYPOINT_ROOT}, skipping configuration"
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#!/bin/bash
|
||||
set -e -o errexit -o nounset -o pipefail
|
||||
|
||||
: ${ENTRYPOINT_DEBUG:=0}
|
||||
|
||||
[[ ${ENTRYPOINT_DEBUG} == 1 ]] && set -x
|
||||
|
||||
# Some splash of color for important messages
|
||||
declare -g error_message_color="\033[1;31m"
|
||||
declare -g warn_message_color="\033[1;34m"
|
||||
|
@ -110,6 +114,14 @@ function is-executable() {
|
|||
[[ -x "$1" ]]
|
||||
}
|
||||
|
||||
function is-writable() {
|
||||
[[ -w "$1" ]]
|
||||
}
|
||||
|
||||
function ensure-directory() {
|
||||
mkdir -pv "$@"
|
||||
}
|
||||
|
||||
function get-entrypoint-script-name() {
|
||||
echo "${1#"$ENTRYPOINT_ROOT"}"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue