🗃️ Committing everything that changed 🗃️

This commit is contained in:
casjay 2022-10-18 16:56:26 -04:00
parent 456c7bb5f6
commit fdd2873127
No known key found for this signature in database
GPG Key ID: 4F765975C1F0EE5F
3 changed files with 72 additions and 61 deletions

View File

@ -1,4 +1,4 @@
FROM casjaysdevdocker/php:latest AS build FROM casjaysdevdocker/alpine:latest AS build
ARG ALPINE_VERSION="v3.16" ARG ALPINE_VERSION="v3.16"
@ -10,7 +10,9 @@ ENV LANG=en_US.utf8 \
ENV=ENV=~/.bashrc \ ENV=ENV=~/.bashrc \
TZ="America/New_York" \ TZ="America/New_York" \
SHELL="/bin/sh" \ SHELL="/bin/sh" \
TERM="xterm-256color" TERM="xterm-256color" \
TIMEZONE="${TZ:-$TIMEZONE}" \
HOSTNAME="casjaysdev-lighttpd"
COPY ./rootfs/. / COPY ./rootfs/. /
@ -22,11 +24,10 @@ RUN set -ex; \
if [ "${ALPINE_VERSION}" = "edge" ]; then echo "http://dl-cdn.alpinelinux.org/alpine/${ALPINE_VERSION}/testing" >>"/etc/apk/repositories" ; fi ; \ if [ "${ALPINE_VERSION}" = "edge" ]; then echo "http://dl-cdn.alpinelinux.org/alpine/${ALPINE_VERSION}/testing" >>"/etc/apk/repositories" ; fi ; \
apk update --update-cache && apk add \ apk update --update-cache && apk add \
bash iproute2 \ bash iproute2 \
lighttpd \ lighttpd lighttpd-mod_auth lighttpd-mod_webdav && \
lighttpd-mod_auth \
lighttpd-mod_webdav && \
cp -Rf "/etc/lighttpd" "$DEFAULT_TEMPLATE_DIR/lighttpd" cp -Rf "/etc/lighttpd" "$DEFAULT_TEMPLATE_DIR/lighttpd"
RUN echo 'Running cleanup' ; \ RUN echo 'Running cleanup' ; \
rm -Rf /usr/share/doc/* /usr/share/info/* /tmp/* /var/tmp/* ; rm -Rf /usr/local/bin/.gitkeep /usr/local/bin/.gitkeep /config /data /var/cache/apk/* ; \ rm -Rf /usr/share/doc/* /usr/share/info/* /tmp/* /var/tmp/* ; rm -Rf /usr/local/bin/.gitkeep /usr/local/bin/.gitkeep /config /data /var/cache/apk/* ; \
rm -rf /lib/systemd/system/multi-user.target.wants/* ; \ rm -rf /lib/systemd/system/multi-user.target.wants/* ; \
@ -49,7 +50,7 @@ ARG \
BUILD_VERSION="latest" \ BUILD_VERSION="latest" \
LICENSE="MIT" \ LICENSE="MIT" \
IMAGE_NAME="lighttpd" \ IMAGE_NAME="lighttpd" \
BUILD_DATE="Tue 18 Oct 2022 01:14:04 PM EDT" \ BUILD_DATE="Tue 18 Oct 2022 04:46:07 PM EDT" \
TIMEZONE="America/New_York" TIMEZONE="America/New_York"
LABEL maintainer="CasjaysDev <docker-admin@casjaysdev.com>" \ LABEL maintainer="CasjaysDev <docker-admin@casjaysdev.com>" \

View File

@ -1,13 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash # shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202210181314-git ##@Version : 202210181646-git
# @@Author : Jason Hempstead # @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.com # @@Contact : jason@casjaysdev.com
# @@License : LICENSE.md # @@License : LICENSE.md
# @@ReadME : entrypoint-lighttpd.sh --help # @@ReadME : entrypoint-lighttpd.sh --help
# @@Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments # @@Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
# @@Created : Tuesday, Oct 18, 2022 13:14 EDT # @@Created : Tuesday, Oct 18, 2022 16:46 EDT
# @@File : entrypoint-lighttpd.sh # @@File : entrypoint-lighttpd.sh
# @@Description : # @@Description :
# @@Changelog : New script # @@Changelog : New script
@ -22,7 +22,7 @@
[ -n "$DEBUG" ] && set -x [ -n "$DEBUG" ] && set -x
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
APPNAME="$(basename "$0" 2>/dev/null)" APPNAME="$(basename "$0" 2>/dev/null)"
VERSION="202210181314-git" VERSION="202210181646-git"
HOME="${USER_HOME:-$HOME}" HOME="${USER_HOME:-$HOME}"
USER="${SUDO_USER:-$USER}" USER="${SUDO_USER:-$USER}"
RUN_USER="${SUDO_USER:-$USER}" RUN_USER="${SUDO_USER:-$USER}"
@ -39,9 +39,10 @@ __exec_command() {
} }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Additional functions # Additional functions
__pgrep() { ps aux 2>/dev/null | grep -F "$@" | grep -qv 'grep' || return 10; } __pcheck() { [ -n "$(which pgrep 2>/dev/null)" ] && pgrep "$1" || return 1; }
__find() { find "$1" -mindepth 1 -type f,d 2>/dev/null | grep '^' || return 10; } __find() { find "$1" -mindepth 1 -type f,d 2>/dev/null | grep '^' || return 10; }
__curl() { curl -q -LSsf -o /dev/null -s -w "200" "$@" 2>/dev/null || return 10; } __curl() { curl -q -LSsf -o /dev/null -s -w "200" "$@" 2>/dev/null || return 10; }
__pgrep() { __pcheck "$1" || ps aux 2>/dev/null | grep -F " $1" | grep -qv 'grep' || return 10; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__certbot() { __certbot() {
[ -n "$SSL_CERT_BOT" ] && type -P certbot &>/dev/null || { export SSL_CERT_BOT="" && return 10; } [ -n "$SSL_CERT_BOT" ] && type -P certbot &>/dev/null || { export SSL_CERT_BOT="" && return 10; }
@ -89,10 +90,14 @@ CONTAINER_IP_ADDRESS="$(ip a | grep 'inet' | grep -v '127.0.0.1' | awk '{print $
# Additional variables and variable overrides # Additional variables and variable overrides
#export SERVICE_NAME="" #export SERVICE_NAME=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Check if this is a new container
[ -f "/data/.docker_has_run" ] && DATA_DIR_INITIALIZED="true" || DATA_DIR_INITIALIZED="false"
[ -f "/config/.docker_has_run" ] && CONFIG_DIR_INITIALIZED="true" || CONFIG_DIR_INITIALIZED="false"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# export variables # export variables
export LANG TZ DOMANNAME HOSTNAME HOSTADMIN SSL_ENABLED SSL_DIR SSL_CA SSL_KEY export LANG TZ DOMANNAME HOSTNAME HOSTADMIN SSL_ENABLED SSL_DIR SSL_CA SSL_KEY
export SSL_DIR HTTP_PORT HTTPS_PORT LOCAL_BIN_DIR DEFAULT_CONF_DIR CONTAINER_IP_ADDRESS export SSL_DIR HTTP_PORT HTTPS_PORT LOCAL_BIN_DIR DEFAULT_CONF_DIR CONTAINER_IP_ADDRESS
export SSL_CONTAINER_DIR SSL_CERT_BOT DISPLAY export SSL_CONTAINER_DIR SSL_CERT_BOT DISPLAY CONFIG_DIR_INITIALIZED DATA_DIR_INITIALIZED
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# import variables from file # import variables from file
[ -f "/root/env.sh" ] && . "/root/env.sh" [ -f "/root/env.sh" ] && . "/root/env.sh"
@ -125,10 +130,9 @@ fi
[ -d "/etc/ssl" ] || mkdir -p "$SSL_CONTAINER_DIR" [ -d "/etc/ssl" ] || mkdir -p "$SSL_CONTAINER_DIR"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create files # Create files
touch "/tmp/lighttpd.err.log"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create symlinks # Create symlinks
ln -sf "/tmp/lighttpd.err.log" "/dev/stderr" && chmod 666 "/tmp/lighttpd.err.log"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ "$SSL_ENABLED" = "true" ] || [ "$SSL_ENABLED" = "yes" ]; then if [ "$SSL_ENABLED" = "true" ] || [ "$SSL_ENABLED" = "yes" ]; then
@ -156,51 +160,53 @@ if [ -d "/data/bin" ]; then
create_bin_name="$(basename "$create_bin")" create_bin_name="$(basename "$create_bin")"
ln -sf "$create_bin" "/usr/local/bin/$create_bin_name" ln -sf "$create_bin" "/usr/local/bin/$create_bin_name"
done done
unset create_bin create_bin_name fi # create_bin create_bin_name
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create default config # Create default config
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then
if [ -n "$DEFAULT_TEMPLATE_DIR" ] && [ -d "$DEFAULT_TEMPLATE_DIR" ]; then if [ -n "$DEFAULT_TEMPLATE_DIR" ] && [ -d "$DEFAULT_TEMPLATE_DIR" ]; then
for create_template in "$DEFAULT_TEMPLATE_DIR"/*; do for create_template in "$DEFAULT_TEMPLATE_DIR"/*; do
create_template_name="$(basename "$create_template")" create_template_name="$(basename "$create_template")"
if [ ! -e "/config/$create_template_name" ]; then
cp -Rf "$create_template" "/config/$create_template_name" cp -Rf "$create_template" "/config/$create_template_name"
fi
done done
unset create_template create_template_name fi
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Copy custom config files # Copy custom config files
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then
for create_config in "$DEFAULT_CONF_DIR"/*; do for create_config in "$DEFAULT_CONF_DIR"/*; do
create_config_name="$(basename "$create_config")" create_config_name="$(basename "$create_config")"
if [ ! -e "/config/$create_config_name" ]; then
cp -Rf "$create_config" "/config/$create_config_name" cp -Rf "$create_config" "/config/$create_config_name"
fi
done done
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Copy custom data files # Copy custom data files
if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -d "/data" ]; then
for create_data in "$DEFAULT_DATA_DIR"/*; do for create_data in "$DEFAULT_DATA_DIR"/*; do
create_data_name="$(basename "$create_data")" create_data_name="$(basename "$create_data")"
if [ ! -e "/data/$create_data_name" ]; then
cp -Rf "$create_data" "/data/$create_data_name" cp -Rf "$create_data" "/data/$create_data_name"
fi
done done
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Unset unneeded variables # Copy /config to /etc
unset create_data create_data_name create_config create_config_name
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create config symlinks
if [ -d "/config" ]; then if [ -d "/config" ]; then
for create_conf in /config/*; do for create_conf in /config/*; do
if [ -n "$create_conf" ]; then
create_conf_name="$(basename "$create_conf")" create_conf_name="$(basename "$create_conf")"
if [ -e "/etc/$create_conf_name" ]; then if [ -e "/etc/$create_conf_name" ]; then
rm -Rf "/etc/${create_conf_name:?}" cp -Rf "$create_conf" "/etc/$create_conf_name"
ln -sf "$create_conf" "/etc/$create_conf_name" fi
fi fi
done done
unset create_conf create_conf_name
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Unset unneeded variables
unset create_bin create_bin_name create_template create_template_name
unset create_data create_data_name create_config create_config_name create_conf create_conf_name
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ -f "/data/.docker_has_run" ] || { [ -d "/data" ] && echo "Initialized on: $(date)" >"/data/.docker_has_run"; }
[ -f "/config/.docker_has_run" ] || { [ -d "/config" ] && echo "Initialized on: $(date)" >"/config/.docker_has_run"; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Additional commands # Additional commands
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -227,8 +233,7 @@ healthcheck) # Docker healthcheck
*) # Execute primary command *) # Execute primary command
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
echo "Container ip address is: $CONTAINER_IP_ADDRESS" echo "Container ip address is: $CONTAINER_IP_ADDRESS"
php-fpm-server & start-lighttpd.sh
start-lighttpd
exit ${exitCode:-$?} exit ${exitCode:-$?}
else else
__exec_command "$@" __exec_command "$@"

View File

@ -1,14 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck shell=bash # shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202210181320-git ##@Version : 202210181648-git
# @@Author : Jason Hempstead # @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.com # @@Contact : jason@casjaysdev.com
# @@License : LICENSE.md # @@License : LICENSE.md
# @@ReadME : start-lighttpd --help # @@ReadME : start-lighttpd.sh --help
# @@Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments # @@Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
# @@Created : Tuesday, Oct 18, 2022 13:20 EDT # @@Created : Tuesday, Oct 18, 2022 16:48 EDT
# @@File : start-lighttpd # @@File : start-lighttpd.sh
# @@Description : # @@Description :
# @@Changelog : New script # @@Changelog : New script
# @@TODO : Better documentation # @@TODO : Better documentation
@ -19,9 +19,10 @@
# @@Template : other/start-service # @@Template : other/start-service
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set functions # Set functions
__pgrep() { ps aux 2>/dev/null | grep -Fw " $@" | grep -qv 'grep' || return 10; } __pcheck() { [ -n "$(which pgrep 2>/dev/null)" ] && pgrep "$1" || return 1; }
__find() { find "$1" -mindepth 1 -type f,d 2>/dev/null | grep '^' || return 10; } __find() { find "$1" -mindepth 1 -type f,d 2>/dev/null | grep '^' || return 10; }
__curl() { curl -q -LSsf -o /dev/null -s -w "200" "$@" 2>/dev/null || return 10; } __curl() { curl -q -LSsf -o /dev/null -s -w "200" "$@" 2>/dev/null || return 10; }
__pgrep() { __pcheck "$1" || ps aux 2>/dev/null | grep -F " $1" | grep -qv 'grep' || return 10; }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
__certbot() { __certbot() {
[ -n "$SSL_CERT_BOT" ] && type -P certbot &>/dev/null || { export SSL_CERT_BOT="" && return 10; } [ -n "$SSL_CERT_BOT" ] && type -P certbot &>/dev/null || { export SSL_CERT_BOT="" && return 10; }
@ -47,7 +48,7 @@ HTTP_PORT="${HTTP_PORT:-80}"
HTTPS_PORT="${HTTPS_PORT:-443}" HTTPS_PORT="${HTTPS_PORT:-443}"
SERVICE_PORT="${SERVICE_PORT:-}" SERVICE_PORT="${SERVICE_PORT:-}"
SERVICE_NAME="${CONTAINER_NAME}" SERVICE_NAME="${CONTAINER_NAME}"
HOSTNAME="${HOSTNAME:-casjaysdev-bin}" HOSTNAME="${HOSTNAME:-casjaysdev-lighttpd}"
HOSTADMIN="${HOSTADMIN:-root@${DOMANNAME:-$HOSTNAME}}" HOSTADMIN="${HOSTADMIN:-root@${DOMANNAME:-$HOSTNAME}}"
SSL_CERT_BOT="${SSL_CERT_BOT:-false}" SSL_CERT_BOT="${SSL_CERT_BOT:-false}"
SSL_ENABLED="${SSL_ENABLED:-false}" SSL_ENABLED="${SSL_ENABLED:-false}"
@ -64,31 +65,33 @@ DEFAULT_TEMPLATE_DIR="${DEFAULT_TEMPLATE_DIR:-/usr/local/share/template-files/de
CONTAINER_IP_ADDRESS="$(ip a | grep 'inet' | grep -v '127.0.0.1' | awk '{print $2}' | sed 's|/*||g')" CONTAINER_IP_ADDRESS="$(ip a | grep 'inet' | grep -v '127.0.0.1' | awk '{print $2}' | sed 's|/*||g')"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Overwrite variables # Overwrite variables
SERVICE_NAME="lighttpd" #SERVICE_NAME=""
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Create default config # Create default config
if [ -n "$DEFAULT_TEMPLATE_DIR" ] && [ -d "$DEFAULT_TEMPLATE_DIR/$SERVICE_NAME" ]; then if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_TEMPLATE_DIR" ]; then
if [ ! -e "/config/$SERVICE_NAME" ]; then [ -d "/config" ] && cp -Rf "$DEFAULT_TEMPLATE_DIR/." "/config/"
cp -Rf "$DEFAULT_TEMPLATE_DIR/$SERVICE_NAME" "/config/$SERVICE_NAME"
fi
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Copy custom config files # Copy custom config files
if [ -n "$DEFAULT_CONF_DIR" ] && [ ! -e "/config/$SERVICE_NAME" ]; then if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_CONF_DIR" ]; then
cp -Rf "$DEFAULT_CONF_DIR/$SERVICE_NAME" "/config/$SERVICE_NAME" [ -d "/config" ] && cp -Rf "$DEFAULT_CONF_DIR/." "/config/"
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Copy custom data files # Copy custom data files
if [ -n "$DEFAULT_DATA_DIR" ] && [ ! -e "/data/$SERVICE_NAME" ]; then if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_DATA_DIR" ]; then
cp -Rf "$DEFAULT_DATA_DIR/$SERVICE_NAME" "/data/$SERVICE_NAME" [ -d "/data" ] && cp -Rf "$DEFAULT_DATA_DIR/." "/data/"
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Copy html files # Copy html files
if [ -z "$(__find "$WWW_ROOT_DIR/www")" ] && [ -d "$DEFAULT_DATA_DIR/data/htdocs" ]; then if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -d "$DEFAULT_DATA_DIR/data/htdocs" ]; then
cp -Rf "$DEFAULT_DATA_DIR/data/htdocs/." "$WWW_ROOT_DIR/" [ -d "/data" ] && cp -Rf "$DEFAULT_DATA_DIR/data/htdocs/." "$WWW_ROOT_DIR/"
fi fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Initialized
[ -d "/data" ] && touch "/data/.docker_has_run"
[ -d "/config" ] && touch "/config/.docker_has_run"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# APP Variables overrides # APP Variables overrides
[ -f "/root/env.sh" ] && . "/root/env.sh" [ -f "/root/env.sh" ] && . "/root/env.sh"
[ -f "/config/env.sh" ] && "/config/env.sh" [ -f "/config/env.sh" ] && "/config/env.sh"
@ -108,7 +111,9 @@ healthcheck)
if __pgrep "$SERVICE_NAME"; then if __pgrep "$SERVICE_NAME"; then
echo "$SERVICE_NAME is running" echo "$SERVICE_NAME is running"
else else
exec lighttpd -f /config/lighttpd/lighttpd.conf -D echo "Starting $SERVICE_NAME"
php-fpm-server &
start-lighttpd
fi fi
;; ;;
esac esac