Autocreate our encryption key when container starts if it isnt already set
All checks were successful
Create Docker Image / Test Application (x86_64) (push) Successful in 31s
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 1m23s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 3m37s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s

This commit is contained in:
Deon George 2025-01-13 09:22:00 +11:00
parent 565435403f
commit fcec58441f
2 changed files with 13 additions and 5 deletions

View File

@ -8,6 +8,10 @@ RUN install-php-extensions \
ldap \
memcached
RUN sed -i -e 's/^{$CADDY_EXTRA_CONFIG}$/{$CADDY_EXTRA_CONFIG} /' /etc/caddy/Caddyfile
RUN sed -i -e 's/^memory_limit = 128M/memory_limit = 1G/' /usr/local/etc/php/php.ini-production
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
RUN curl -4 https://getcomposer.org/installer|php -- --install-dir=/usr/local/bin --filename=composer
ENV COMPOSER_HOME=/var/cache/composer
@ -23,13 +27,10 @@ RUN mkdir -p ${COMPOSER_HOME} \
&& ([ -r auth.json ] && mv auth.json ${COMPOSER_HOME}) || true \
&& touch .composer.refresh \
&& mv .env.example .env \
&& FORCE_PERMS=1 /sbin/init-docker \
&& FORCE_PERMS=1 BUILD=1 /sbin/init-docker \
&& rm -rf ${COMPOSER_HOME}/* composer.lock
# Fix start up items
RUN sed -i -e 's/^{$CADDY_EXTRA_CONFIG}$/{$CADDY_EXTRA_CONFIG} /' /etc/caddy/Caddyfile
RUN sed -i -e 's/^memory_limit = 128M/memory_limit = 1G/' /usr/local/etc/php/php.ini-production
RUN cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
RUN chown ${SITE_USER} /config/caddy /data/caddy
USER ${SITE_USER}

View File

@ -50,10 +50,11 @@ fi
if [ -r artisan -a -e ${php}/.env ]; then
echo "* Laravel Setup..."
mp=$(mp ${php})
echo " - [${php}] is a mount point [${mp}]"
# Only adjust perms if this is an external mountpoint
if [ -n "${FORCE_PERMS}" -o ${mp} -eq 0 ]; then
echo " - ${mp} is an external mount point"
if [ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ]; then
echo " - Setting Permissions..."
# Make sure our permissions are appropraite
@ -96,6 +97,12 @@ if [ -r artisan -a -e ${php}/.env ]; then
[ -n "${FORCE_PERMS}" -o "${env}" != "local" -a -z "${SKIP_PERM}" ] && [ ${mp} -eq 0 ] && chmod g-w ${php}
fi
# Generate our Encryption Key
[ -z ${BUILD} ] && [ -z ${APP_KEY} ] \
&& grep -qe '^APP_KEY=$' .env \
&& echo ' + Encryption Key auto created, replace with with "artisan key:generate --force"' \
&& ./artisan key:generate
# We only check for non mount points, in case this container has the app inside
mp=$(mp ${php})
if [ ${mp} -eq 1 ]; then