feat(): improve startup script
parent
167df1e870
commit
c35209a401
12
Dockerfile
12
Dockerfile
|
@ -9,7 +9,15 @@ ENV GID=991 \
|
||||||
UID=991 \
|
UID=991 \
|
||||||
UPLOAD_MAX_SIZE=50M \
|
UPLOAD_MAX_SIZE=50M \
|
||||||
PHP_MEMORY_LIMIT=128M \
|
PHP_MEMORY_LIMIT=128M \
|
||||||
OPCACHE_MEMORY_LIMIT=128
|
OPCACHE_MEMORY_LIMIT=128 \
|
||||||
|
DB_HOST=mariadb \
|
||||||
|
DB_USER=flarum \
|
||||||
|
DB_NAME=flarum \
|
||||||
|
DB_PORT=3306 \
|
||||||
|
FLARUM_TITLE=Docker-Flarum \
|
||||||
|
DEBUG=false \
|
||||||
|
LOG_TO_STDOUT=false \
|
||||||
|
GITHUB_TOKEN_AUTH=false
|
||||||
|
|
||||||
RUN apk add --no-progress --no-cache \
|
RUN apk add --no-progress --no-cache \
|
||||||
nginx \
|
nginx \
|
||||||
|
@ -47,7 +55,7 @@ RUN apk add --no-progress --no-cache \
|
||||||
&& COMPOSER_CACHE_DIR="/tmp" su-exec $UID:$GID composer create-project --stability=beta --no-progress -- flarum/flarum /flarum/app $VERSION \
|
&& COMPOSER_CACHE_DIR="/tmp" su-exec $UID:$GID composer create-project --stability=beta --no-progress -- flarum/flarum /flarum/app $VERSION \
|
||||||
&& composer clear-cache \
|
&& composer clear-cache \
|
||||||
&& rm -rf /flarum/.composer /tmp/* \
|
&& rm -rf /flarum/.composer /tmp/* \
|
||||||
&& apk del --purge curl
|
&& apk del --purge curl git
|
||||||
|
|
||||||
COPY rootfs /
|
COPY rootfs /
|
||||||
RUN chmod +x /usr/local/bin/* /services/*/run /services/.s6-svscan/*
|
RUN chmod +x /usr/local/bin/* /services/*/run /services/.s6-svscan/*
|
||||||
|
|
|
@ -19,8 +19,8 @@ action="${1}"
|
||||||
package="${2}"
|
package="${2}"
|
||||||
|
|
||||||
# Create custom extensions cache folder and list file
|
# Create custom extensions cache folder and list file
|
||||||
su-exec $UID:$GID mkdir -p "${CACHE_DIR}"
|
su-exec "${UID}:${GID}" mkdir -p "${CACHE_DIR}"
|
||||||
su-exec $UID:$GID touch "${LIST_FILE}"
|
su-exec "${UID}:${GID}" touch "${LIST_FILE}"
|
||||||
|
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
# Install a flarum extension
|
# Install a flarum extension
|
||||||
|
@ -54,6 +54,6 @@ case "${action}" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
su-exec $UID:$GID php /flarum/app/flarum cache:clear
|
su-exec "${UID}:${GID}" php /flarum/app/flarum cache:clear
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# Default values
|
|
||||||
DB_HOST="${DB_HOST:-mariadb}"
|
|
||||||
DB_USER="${DB_USER:-flarum}"
|
|
||||||
DB_NAME="${DB_NAME:-flarum}"
|
|
||||||
DB_PORT="${DB_PORT:-3306}"
|
|
||||||
FLARUM_TITLE="${FLARUM_TITLE:-Docker-Flarum}"
|
|
||||||
DEBUG="${DEBUG:-false}"
|
|
||||||
LOG_TO_STDOUT="${LOG_TO_STDOUT:-false}"
|
|
||||||
GITHUB_TOKEN_AUTH="${GITHUB_TOKEN_AUTH:-false}"
|
|
||||||
|
|
||||||
# Required env variables
|
# Required env variables
|
||||||
if [ -z "${DB_PASS}" ]; then
|
if [ -z "${DB_PASS}" ]; then
|
||||||
echo "[ERROR] Mariadb database password must be set !"
|
echo "[ERROR] Mariadb database password must be set !"
|
||||||
|
@ -27,7 +17,7 @@ sed -i "s/<PHP_MEMORY_LIMIT>/${PHP_MEMORY_LIMIT}/g" /etc/php7/php-fpm.conf
|
||||||
sed -i "s/<OPCACHE_MEMORY_LIMIT>/${OPCACHE_MEMORY_LIMIT}/g" /etc/php7/conf.d/00_opcache.ini
|
sed -i "s/<OPCACHE_MEMORY_LIMIT>/${OPCACHE_MEMORY_LIMIT}/g" /etc/php7/conf.d/00_opcache.ini
|
||||||
|
|
||||||
# Set permissions
|
# Set permissions
|
||||||
chown -R $UID:$GID /services /var/log /var/lib/nginx
|
chown -R "${UID}:${GID}" /services /var/log /var/lib/nginx
|
||||||
|
|
||||||
# Set log output to STDOUT if wanted (LOG_TO_STDOUT=true)
|
# Set log output to STDOUT if wanted (LOG_TO_STDOUT=true)
|
||||||
if [ "${LOG_TO_STDOUT}" = true ]; then
|
if [ "${LOG_TO_STDOUT}" = true ]; then
|
||||||
|
@ -48,8 +38,8 @@ fi
|
||||||
# Custom repositories (eg. for privates extensions)
|
# Custom repositories (eg. for privates extensions)
|
||||||
if [ -f '/flarum/app/extensions/composer.repositories.txt' ]; then
|
if [ -f '/flarum/app/extensions/composer.repositories.txt' ]; then
|
||||||
while read line; do
|
while read line; do
|
||||||
repository=$(echo $line | cut -d '|' -f1)
|
repository="$(echo ${line} | cut -d '|' -f1)"
|
||||||
json=$(echo $line | cut -d '|' -f2)
|
json="$(echo ${line} | cut -d '|' -f2)"
|
||||||
echo "[INFO] Adding ${repository} composer repository"
|
echo "[INFO] Adding ${repository} composer repository"
|
||||||
composer config repositories."${repository}" "${json}"
|
composer config repositories."${repository}" "${json}"
|
||||||
done < /flarum/app/extensions/composer.repositories.txt
|
done < /flarum/app/extensions/composer.repositories.txt
|
||||||
|
@ -77,7 +67,7 @@ if [ -e '/flarum/app/public/assets/rev-manifest.json' ]; then
|
||||||
-e "s|<FORUM_URL>|${FORUM_URL}|g" /flarum/app/config.php.sample
|
-e "s|<FORUM_URL>|${FORUM_URL}|g" /flarum/app/config.php.sample
|
||||||
|
|
||||||
cp /flarum/app/config.php.sample /flarum/app/config.php
|
cp /flarum/app/config.php.sample /flarum/app/config.php
|
||||||
su-exec $UID:$GID php /flarum/app/flarum cache:clear
|
su-exec "${UID}:${GID}" php /flarum/app/flarum cache:clear
|
||||||
|
|
||||||
# Composer cache dir and packages list paths
|
# Composer cache dir and packages list paths
|
||||||
CACHE_DIR=/flarum/app/extensions/.cache
|
CACHE_DIR=/flarum/app/extensions/.cache
|
||||||
|
@ -90,7 +80,7 @@ if [ -e '/flarum/app/public/assets/rev-manifest.json' ]; then
|
||||||
extension="${extension}${line} "
|
extension="${extension}${line} "
|
||||||
done < /flarum/app/extensions/list
|
done < /flarum/app/extensions/list
|
||||||
cmd="composer require ${extension}"
|
cmd="composer require ${extension}"
|
||||||
COMPOSER_CACHE_DIR="${CACHE_DIR}" eval $cmd
|
COMPOSER_CACHE_DIR="${CACHE_DIR}" eval "${cmd}"
|
||||||
echo "[INFO] Install extra bundled extensions: DONE."
|
echo "[INFO] Install extra bundled extensions: DONE."
|
||||||
else
|
else
|
||||||
echo "[INFO] No installed extensions"
|
echo "[INFO] No installed extensions"
|
||||||
|
@ -120,15 +110,15 @@ else
|
||||||
-e "s|<FLARUM_TITLE>|${FLARUM_TITLE}|g" /flarum/app/config.yml
|
-e "s|<FLARUM_TITLE>|${FLARUM_TITLE}|g" /flarum/app/config.yml
|
||||||
|
|
||||||
# Install flarum
|
# Install flarum
|
||||||
chown -R $UID:$GID /flarum
|
chown -R "${UID}:${GID}" /flarum
|
||||||
su-exec $UID:$GID php /flarum/app/flarum install --file=/flarum/app/config.yml
|
su-exec "${UID}:${GID}" php /flarum/app/flarum install --file=/flarum/app/config.yml
|
||||||
|
|
||||||
echo "[INFO] End of flarum installation"
|
echo "[INFO] End of flarum installation"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set permissions for /flarum folder
|
# Set permissions for /flarum folder
|
||||||
find /flarum ! -user $UID -print0 | xargs -0 -r chown $UID:$GID
|
find /flarum ! -user "${UID}" -exec chown "${UID}:${GID}" {} \;
|
||||||
find /flarum ! -group $GID -print0 | xargs -0 -r chown $UID:$GID
|
find /flarum ! -group "${GID}" -exec chown "${UID}:${GID}" {} \;
|
||||||
|
|
||||||
# RUN !
|
# RUN !
|
||||||
exec su-exec $UID:$GID /bin/s6-svscan /services
|
exec su-exec "${UID}:${GID}" /bin/s6-svscan /services
|
||||||
|
|
Loading…
Reference in New Issue