From 5392cca13bf6dbfee2689580609e9451bcde0f3f Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Wed, 7 Feb 2024 13:37:27 +0100 Subject: [PATCH] Fixes, BoltCMS --- README.md | 22 ++++++++++++++++++++++ config/frameworks/10-symfony.sh | 19 ++++++++++++++++--- config/frameworks/90-composer.sh | 2 +- config/frameworks/99-sorry.sh | 2 +- templates/bolt.Dockerfile | 13 +++++++++++++ templates/symfony.Dockerfile | 4 +++- 6 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 templates/bolt.Dockerfile diff --git a/README.md b/README.md index 96fb4e7..0b95493 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,25 @@ # NoccyLabs PHP 8.3 Alpine All-in-One Base Image +This is an AIO container done mostly right. It contains Nginx, PHP 8.3 and FPM preconfigured. It also comes with a watchdog that ensures that a failure will bring down the container, allowing for self-healing by recreating containers. +## Features + +* Nginx and PHP in a single container. +* Framework detection. +* Plenty of hooks. + +## Frameworks + +### Symfony + +Symfony projects are detected from the `symfony.lock` file. + +The support will ensure that composer is installed, and that the cache directory is writable. + +#### BoltCMS + +BoltCMS is detected and configured by the Symfony framework support script. + +### Composer + +While not a frarmework, as a last resort the presence of a `composer.json` file will trigger an install. diff --git a/config/frameworks/10-symfony.sh b/config/frameworks/10-symfony.sh index 457ba11..a6328be 100644 --- a/config/frameworks/10-symfony.sh +++ b/config/frameworks/10-symfony.sh @@ -7,10 +7,10 @@ fi # Determine if this is a specific variant of Symfny if [ -d /application/config/bolt ]; then - echo " => Detected Symfony (Bolt) project" + echo " => Detected Symfony (Bolt) project" VARIANT=bolt else - echo " => Detected Symfony project" + echo " => Detected Symfony project" VARIANT=vanilla fi @@ -41,11 +41,24 @@ case "$VARIANT" in echo " -> Clearing cache..." bin/console cache:clear --env=prod -q ;; + "bolt") + echo " -> Setting up BoltCMS directories..." + # we get a warning about this + chmod a+rwx /bolt/config + # we don't want to get errors from these + chmod -R a+rwx /bolt/var + chmod -R a+rwx /bolt/var/data + chmod -R a+rwx /bolt/var/cache + chmod -R a+rwx /bolt/var/cache/prod + chmod -R a+rwx /bolt/var/log + echo " -> Configuring database..." + # TODO: Apply schema and migrations + ;; esac echo " -> Testing environment..." if ! bin/console about -q; then - echo " >> Failed" + echo " ** Failed **" fi exit 0 diff --git a/config/frameworks/90-composer.sh b/config/frameworks/90-composer.sh index a0b2633..97c596c 100644 --- a/config/frameworks/90-composer.sh +++ b/config/frameworks/90-composer.sh @@ -4,7 +4,7 @@ if [ ! -f /application/composer.json ]; then exit 1 fi -echo " => Detected composer project." +echo " => Detected composer project." echo " -> Installing dependencies using composer..." /usr/bin/composer install --no-dev --no-cache --optimize-autoloader --no-progress -q || exit 0 diff --git a/config/frameworks/99-sorry.sh b/config/frameworks/99-sorry.sh index 3074ff1..7dccd0e 100644 --- a/config/frameworks/99-sorry.sh +++ b/config/frameworks/99-sorry.sh @@ -1,3 +1,3 @@ #!/bin/sh -echo " ** Sorry, no framework detected." +echo " ** Sorry, no framework detected **" diff --git a/templates/bolt.Dockerfile b/templates/bolt.Dockerfile new file mode 100644 index 0000000..8589d42 --- /dev/null +++ b/templates/bolt.Dockerfile @@ -0,0 +1,13 @@ +# +# Dockerfile template for BoltCMS (Symfony) based projects using PHP 8.3 +# +# Magic files (in /application): +# +# .nginx-site.conf Override nginx site default.conf +# + +FROM dev.noccylabs.info/noccylabs/alpine-php83-aio:latest + +COPY . /application + +VOLUME /application/var /application/public/thumbs /application/public/files diff --git a/templates/symfony.Dockerfile b/templates/symfony.Dockerfile index 90acee5..5fe328d 100644 --- a/templates/symfony.Dockerfile +++ b/templates/symfony.Dockerfile @@ -3,7 +3,7 @@ # # Magic files (in /application): # -# .nginx-site Override nginx site default.conf +# .nginx-site.conf Override nginx site default.conf # .symfony-preinit Called before composer install # .symfony-init Called after compose install # @@ -11,3 +11,5 @@ FROM dev.noccylabs.info/noccylabs/alpine-php83-aio:latest COPY . /application + +VOLUME /application/var \ No newline at end of file