mirror of
https://github.com/casjaysdevdocker/lighttpd
synced 2025-01-18 00:34:23 -05:00
🗃️ Committing everything that changed 🗃️
This commit is contained in:
parent
456c7bb5f6
commit
fdd2873127
13
Dockerfile
13
Dockerfile
@ -1,4 +1,4 @@
|
||||
FROM casjaysdevdocker/php:latest AS build
|
||||
FROM casjaysdevdocker/alpine:latest AS build
|
||||
|
||||
ARG ALPINE_VERSION="v3.16"
|
||||
|
||||
@ -10,7 +10,9 @@ ENV LANG=en_US.utf8 \
|
||||
ENV=ENV=~/.bashrc \
|
||||
TZ="America/New_York" \
|
||||
SHELL="/bin/sh" \
|
||||
TERM="xterm-256color"
|
||||
TERM="xterm-256color" \
|
||||
TIMEZONE="${TZ:-$TIMEZONE}" \
|
||||
HOSTNAME="casjaysdev-lighttpd"
|
||||
|
||||
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 ; \
|
||||
apk update --update-cache && apk add \
|
||||
bash iproute2 \
|
||||
lighttpd \
|
||||
lighttpd-mod_auth \
|
||||
lighttpd-mod_webdav && \
|
||||
lighttpd lighttpd-mod_auth lighttpd-mod_webdav && \
|
||||
cp -Rf "/etc/lighttpd" "$DEFAULT_TEMPLATE_DIR/lighttpd"
|
||||
|
||||
|
||||
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 /lib/systemd/system/multi-user.target.wants/* ; \
|
||||
@ -49,7 +50,7 @@ ARG \
|
||||
BUILD_VERSION="latest" \
|
||||
LICENSE="MIT" \
|
||||
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"
|
||||
|
||||
LABEL maintainer="CasjaysDev <docker-admin@casjaysdev.com>" \
|
||||
|
@ -1,13 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
##@Version : 202210181314-git
|
||||
##@Version : 202210181646-git
|
||||
# @@Author : Jason Hempstead
|
||||
# @@Contact : jason@casjaysdev.com
|
||||
# @@License : LICENSE.md
|
||||
# @@ReadME : entrypoint-lighttpd.sh --help
|
||||
# @@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
|
||||
# @@Description :
|
||||
# @@Changelog : New script
|
||||
@ -22,7 +22,7 @@
|
||||
[ -n "$DEBUG" ] && set -x
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
APPNAME="$(basename "$0" 2>/dev/null)"
|
||||
VERSION="202210181314-git"
|
||||
VERSION="202210181646-git"
|
||||
HOME="${USER_HOME:-$HOME}"
|
||||
USER="${SUDO_USER:-$USER}"
|
||||
RUN_USER="${SUDO_USER:-$USER}"
|
||||
@ -39,9 +39,10 @@ __exec_command() {
|
||||
}
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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; }
|
||||
__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() {
|
||||
[ -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
|
||||
#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 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_CONTAINER_DIR SSL_CERT_BOT DISPLAY
|
||||
export SSL_CONTAINER_DIR SSL_CERT_BOT DISPLAY CONFIG_DIR_INITIALIZED DATA_DIR_INITIALIZED
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# import variables from file
|
||||
[ -f "/root/env.sh" ] && . "/root/env.sh"
|
||||
@ -125,10 +130,9 @@ fi
|
||||
[ -d "/etc/ssl" ] || mkdir -p "$SSL_CONTAINER_DIR"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Create files
|
||||
touch "/tmp/lighttpd.err.log"
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Create symlinks
|
||||
ln -sf "/tmp/lighttpd.err.log" "/dev/stderr" && chmod 666 "/tmp/lighttpd.err.log"
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
if [ "$SSL_ENABLED" = "true" ] || [ "$SSL_ENABLED" = "yes" ]; then
|
||||
@ -156,51 +160,53 @@ if [ -d "/data/bin" ]; then
|
||||
create_bin_name="$(basename "$create_bin")"
|
||||
ln -sf "$create_bin" "/usr/local/bin/$create_bin_name"
|
||||
done
|
||||
unset create_bin create_bin_name
|
||||
fi
|
||||
fi # create_bin create_bin_name
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Create default config
|
||||
if [ -n "$DEFAULT_TEMPLATE_DIR" ] && [ -d "$DEFAULT_TEMPLATE_DIR" ]; then
|
||||
for create_template in "$DEFAULT_TEMPLATE_DIR"/*; do
|
||||
create_template_name="$(basename "$create_template")"
|
||||
if [ ! -e "/config/$create_template_name" ]; then
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then
|
||||
if [ -n "$DEFAULT_TEMPLATE_DIR" ] && [ -d "$DEFAULT_TEMPLATE_DIR" ]; then
|
||||
for create_template in "$DEFAULT_TEMPLATE_DIR"/*; do
|
||||
create_template_name="$(basename "$create_template")"
|
||||
cp -Rf "$create_template" "/config/$create_template_name"
|
||||
fi
|
||||
done
|
||||
unset create_template create_template_name
|
||||
done
|
||||
fi
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy custom config files
|
||||
for create_config in "$DEFAULT_CONF_DIR"/*; do
|
||||
create_config_name="$(basename "$create_config")"
|
||||
if [ ! -e "/config/$create_config_name" ]; then
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -d "/config" ]; then
|
||||
for create_config in "$DEFAULT_CONF_DIR"/*; do
|
||||
create_config_name="$(basename "$create_config")"
|
||||
cp -Rf "$create_config" "/config/$create_config_name"
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy custom data files
|
||||
for create_data in "$DEFAULT_DATA_DIR"/*; do
|
||||
create_data_name="$(basename "$create_data")"
|
||||
if [ ! -e "/data/$create_data_name" ]; then
|
||||
if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -d "/data" ]; then
|
||||
for create_data in "$DEFAULT_DATA_DIR"/*; do
|
||||
create_data_name="$(basename "$create_data")"
|
||||
cp -Rf "$create_data" "/data/$create_data_name"
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Unset unneeded variables
|
||||
unset create_data create_data_name create_config create_config_name
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Create config symlinks
|
||||
# Copy /config to /etc
|
||||
if [ -d "/config" ]; then
|
||||
for create_conf in /config/*; do
|
||||
create_conf_name="$(basename "$create_conf")"
|
||||
if [ -e "/etc/$create_conf_name" ]; then
|
||||
rm -Rf "/etc/${create_conf_name:?}"
|
||||
ln -sf "$create_conf" "/etc/$create_conf_name"
|
||||
if [ -n "$create_conf" ]; then
|
||||
create_conf_name="$(basename "$create_conf")"
|
||||
if [ -e "/etc/$create_conf_name" ]; then
|
||||
cp -Rf "$create_conf" "/etc/$create_conf_name"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
unset create_conf create_conf_name
|
||||
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
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
@ -227,8 +233,7 @@ healthcheck) # Docker healthcheck
|
||||
*) # Execute primary command
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Container ip address is: $CONTAINER_IP_ADDRESS"
|
||||
php-fpm-server &
|
||||
start-lighttpd
|
||||
start-lighttpd.sh
|
||||
exit ${exitCode:-$?}
|
||||
else
|
||||
__exec_command "$@"
|
||||
|
@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
##@Version : 202210181320-git
|
||||
##@Version : 202210181648-git
|
||||
# @@Author : Jason Hempstead
|
||||
# @@Contact : jason@casjaysdev.com
|
||||
# @@License : LICENSE.md
|
||||
# @@ReadME : start-lighttpd --help
|
||||
# @@ReadME : start-lighttpd.sh --help
|
||||
# @@Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
|
||||
# @@Created : Tuesday, Oct 18, 2022 13:20 EDT
|
||||
# @@File : start-lighttpd
|
||||
# @@Created : Tuesday, Oct 18, 2022 16:48 EDT
|
||||
# @@File : start-lighttpd.sh
|
||||
# @@Description :
|
||||
# @@Changelog : New script
|
||||
# @@TODO : Better documentation
|
||||
@ -19,9 +19,10 @@
|
||||
# @@Template : other/start-service
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# 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; }
|
||||
__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() {
|
||||
[ -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}"
|
||||
SERVICE_PORT="${SERVICE_PORT:-}"
|
||||
SERVICE_NAME="${CONTAINER_NAME}"
|
||||
HOSTNAME="${HOSTNAME:-casjaysdev-bin}"
|
||||
HOSTNAME="${HOSTNAME:-casjaysdev-lighttpd}"
|
||||
HOSTADMIN="${HOSTADMIN:-root@${DOMANNAME:-$HOSTNAME}}"
|
||||
SSL_CERT_BOT="${SSL_CERT_BOT:-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')"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Overwrite variables
|
||||
SERVICE_NAME="lighttpd"
|
||||
#SERVICE_NAME=""
|
||||
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Create default config
|
||||
if [ -n "$DEFAULT_TEMPLATE_DIR" ] && [ -d "$DEFAULT_TEMPLATE_DIR/$SERVICE_NAME" ]; then
|
||||
if [ ! -e "/config/$SERVICE_NAME" ]; then
|
||||
cp -Rf "$DEFAULT_TEMPLATE_DIR/$SERVICE_NAME" "/config/$SERVICE_NAME"
|
||||
fi
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_TEMPLATE_DIR" ]; then
|
||||
[ -d "/config" ] && cp -Rf "$DEFAULT_TEMPLATE_DIR/." "/config/"
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy custom config files
|
||||
if [ -n "$DEFAULT_CONF_DIR" ] && [ ! -e "/config/$SERVICE_NAME" ]; then
|
||||
cp -Rf "$DEFAULT_CONF_DIR/$SERVICE_NAME" "/config/$SERVICE_NAME"
|
||||
if [ "$CONFIG_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_CONF_DIR" ]; then
|
||||
[ -d "/config" ] && cp -Rf "$DEFAULT_CONF_DIR/." "/config/"
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy custom data files
|
||||
if [ -n "$DEFAULT_DATA_DIR" ] && [ ! -e "/data/$SERVICE_NAME" ]; then
|
||||
cp -Rf "$DEFAULT_DATA_DIR/$SERVICE_NAME" "/data/$SERVICE_NAME"
|
||||
if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -n "$DEFAULT_DATA_DIR" ]; then
|
||||
[ -d "/data" ] && cp -Rf "$DEFAULT_DATA_DIR/." "/data/"
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Copy html files
|
||||
if [ -z "$(__find "$WWW_ROOT_DIR/www")" ] && [ -d "$DEFAULT_DATA_DIR/data/htdocs" ]; then
|
||||
cp -Rf "$DEFAULT_DATA_DIR/data/htdocs/." "$WWW_ROOT_DIR/"
|
||||
if [ "$DATA_DIR_INITIALIZED" = "false" ] && [ -d "$DEFAULT_DATA_DIR/data/htdocs" ]; then
|
||||
[ -d "/data" ] && cp -Rf "$DEFAULT_DATA_DIR/data/htdocs/." "$WWW_ROOT_DIR/"
|
||||
fi
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# Initialized
|
||||
[ -d "/data" ] && touch "/data/.docker_has_run"
|
||||
[ -d "/config" ] && touch "/config/.docker_has_run"
|
||||
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
# APP Variables overrides
|
||||
[ -f "/root/env.sh" ] && . "/root/env.sh"
|
||||
[ -f "/config/env.sh" ] && "/config/env.sh"
|
||||
@ -108,7 +111,9 @@ healthcheck)
|
||||
if __pgrep "$SERVICE_NAME"; then
|
||||
echo "$SERVICE_NAME is running"
|
||||
else
|
||||
exec lighttpd -f /config/lighttpd/lighttpd.conf -D
|
||||
echo "Starting $SERVICE_NAME"
|
||||
php-fpm-server &
|
||||
start-lighttpd
|
||||
fi
|
||||
;;
|
||||
esac
|
Loading…
x
Reference in New Issue
Block a user