Minor adjustments to Dockerfile build and init-docker startup
All checks were successful
Create Docker Image / Test Application (x86_64) (push) Successful in 29s
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 1m49s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 4m30s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s

This commit is contained in:
Deon George 2025-02-12 21:05:15 +11:00
parent 9506a01016
commit f82cf33f7f
2 changed files with 18 additions and 17 deletions

View File

@ -8,16 +8,20 @@ RUN install-php-extensions \
ldap \ ldap \
igbinary msgpack memcached igbinary msgpack memcached
RUN sed -i -e 's/^memory_limit = 128M/memory_limit = 256M/' /usr/local/etc/php/php.ini-production # Tune PHP
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
RUN sed -i -e 's/^memory_limit = 128M/memory_limit = 256M/' /usr/local/etc/php/php.ini
RUN sed -i -e 's/^expose_php = On/expose_php = Off/' /usr/local/etc/php/php.ini
# Add composer
RUN curl -4 https://getcomposer.org/installer|php -- --install-dir=/usr/local/bin --filename=composer RUN curl -4 https://getcomposer.org/installer|php -- --install-dir=/usr/local/bin --filename=composer
ENV COMPOSER_HOME=/var/cache/composer ENV COMPOSER_HOME=/var/cache/composer
ENV SITE_USER=www-data ENV SITE_USER=www-data
# Startup for ${SITE_USER}
COPY docker/init-docker /sbin/init-docker COPY docker/init-docker /sbin/init-docker
RUN chmod 550 /sbin/init-docker && chown ${SITE_USER}:0 /sbin/init-docker RUN chmod 550 /sbin/init-docker && chown ${SITE_USER}:0 /sbin/init-docker && chown -R ${SITE_USER}:0 ${XDG_DATA_HOME} ${XDG_CONFIG_HOME}
COPY . /app COPY . /app
@ -28,9 +32,7 @@ RUN mkdir -p ${COMPOSER_HOME} \
&& FORCE_PERMS=1 BUILD=1 /sbin/init-docker \ && FORCE_PERMS=1 BUILD=1 /sbin/init-docker \
&& rm -rf ${COMPOSER_HOME}/* composer.lock && rm -rf ${COMPOSER_HOME}/* composer.lock
# Fix start up items WORKDIR /app
RUN chown ${SITE_USER} /config/caddy /data/caddy
USER ${SITE_USER} USER ${SITE_USER}
# Control which port to open # Control which port to open

View File

@ -6,10 +6,10 @@ env=${APP_ENV:-production}
php=${PHP_DIR:-/app} php=${PHP_DIR:-/app}
composer=${COMPOSER_HOME:-/var/cache/composer} composer=${COMPOSER_HOME:-/var/cache/composer}
RUN_USER=$(id -u -n)
SITE_USER=${SITE_USER:-www-data} SITE_USER=${SITE_USER:-www-data}
MEMCACHED_START=${MEMCACHED_START:-FALSE} MEMCACHED_START=${MEMCACHED_START:-FALSE}
[ "${RUN_USER}" = "deon" ] && USE_SU=1 RUN_USER=$(id -u)
[ "${RUN_USER}" = "0" ] && USE_SU=1
# To run a local queue, running jobs from the queue "hostname" # To run a local queue, running jobs from the queue "hostname"
LOCAL_QUEUE=${LOCAL_QUEUE:-FALSE} LOCAL_QUEUE=${LOCAL_QUEUE:-FALSE}
@ -50,12 +50,11 @@ fi
if [ -r artisan -a -e ${php}/.env ]; then if [ -r artisan -a -e ${php}/.env ]; then
echo "* Laravel Setup..." echo "* Laravel Setup..."
mp=$(mp ${php}) mp=$(mp ${php})
echo " - ${php} is an external mount point ${mp}"
# Only adjust perms if this is an external mountpoint # Only adjust perms if this is an external mountpoint
if [ -n "${FORCE_PERMS}" -o ${mp} -eq 0 ]; then if [ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o ${mp} -eq 0 ]; then
echo " - ${mp} is an external mount point" if [ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ]; then
if [ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ]; then
echo " - Setting Permissions..." echo " - Setting Permissions..."
# Make sure our permissions are appropraite # Make sure our permissions are appropraite
find ${php} -type f -exec chmod 640 {} \; find ${php} -type f -exec chmod 640 {} \;
@ -86,26 +85,26 @@ if [ -r artisan -a -e ${php}/.env ]; then
mp=$(mp ${composer}) mp=$(mp ${composer})
echo " - [${composer}] is a mount point [${mp}]" echo " - [${composer}] is a mount point [${mp}]"
if [ -n "${FORCE_PERMS}" -o ${mp} -eq 0 ]; then if [ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o ${mp} -eq 0 ]; then
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chown -R ${SITE_USER}:www-data ${composer} [ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chown -R ${SITE_USER}:www-data ${composer}
[ ! -d ${php}/vendor ] && mkdir -m 750 ${php}/vendor && chown ${SITE_USER}:www-data ${php}/vendor [ ! -d ${php}/vendor ] && mkdir -m 750 ${php}/vendor && chown ${SITE_USER}:www-data ${php}/vendor
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chmod g+w ${php} [ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && chmod g+w ${php}
fi fi
CMD="composer install --optimize-autoloader ${NODEV}" CMD="composer install --optimize-autoloader ${NODEV}"
(( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}) && ( test -e .composer.refresh && rm -f .composer.refresh ) (( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}) && ( test -e .composer.refresh && rm -f .composer.refresh )
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && [ ${mp} -eq 0 ] && chmod g-w ${php} [ -n "${BUILD}" -o -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && [ ${mp} -eq 0 ] && chmod g-w ${php}
fi fi
# Generate our Encryption Key # Generate our Encryption Key
[ -z ${BUILD} ] && [ -z ${APP_KEY} ] \ [ -z "${BUILD}" ] && [ -z "${APP_KEY}" ] \
&& grep -qe '^APP_KEY=$' .env \ && grep -qe '^APP_KEY=$' .env \
&& echo ' + Encryption Key auto created, replace with with "artisan key:generate --force"' \ && echo ' + Encryption Key auto created, replace with with "artisan key:generate --force"' \
&& ./artisan key:generate && ./artisan key:generate
# We only check for non mount points, in case this container has the app inside # We only check for non mount points, in case this container has the app inside
mp=$(mp ${php}) mp=$(mp ${php})
if [ ${mp} -eq 1 ]; then if [ -z "${BUILD}" -a ${mp} -eq 1 ]; then
echo " - Caching configuration..." echo " - Caching configuration..."
CMD="php artisan optimize" CMD="php artisan optimize"
( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD} ( [ -n "${USE_SU}" ] && su ${SITE_USER} -s /bin/sh -c "${CMD}" ) || ${CMD}