diff --git a/Dockerfile b/Dockerfile index 4d33673..f6545f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -80,13 +80,11 @@ RUN apk add --no-cache --virtual .build-deps \ # - Clean bundled config/users & recreate them with UID 1000 for docker compatability in dev container. # - Create composer directories (since we run as non-root later) +# - Add Default Config RUN deluser --remove-home www-data && adduser -u1000 -D www-data && rm -rf /var/www /usr/local/etc/php-fpm.d/* && \ - mkdir -p /var/www/.composer /app && chown -R www-data:www-data /app /var/www/.composer - + mkdir -p /var/www/.composer /app && chown -R www-data:www-data /app /var/www/.composer; \ # ------------------------------------------------ PHP Configuration --------------------------------------------------- - -# Add Default Config -RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" # Add in Base PHP Config COPY docker/php/base-* $PHP_INI_DIR/conf.d @@ -99,13 +97,13 @@ COPY docker/fpm/*.conf /usr/local/etc/php-fpm.d/ # --------------------------------------------------- Scripts ---------------------------------------------------------- -COPY docker/*-base \ - docker/healthcheck-* \ - docker/command-loop \ +COPY docker/entrypoint/*-base docker/post-build/*-base docker/pre-run/*-base \ + docker/fpm/healthcheck-fpm \ + docker/command-loop \ # to /usr/local/bin/ -RUN chmod +x /usr/local/bin/*-base /usr/local/bin/healthcheck-* /usr/local/bin/command-loop +RUN chmod +x /usr/local/bin/*-base /usr/local/bin/healthcheck-fpm /usr/local/bin/command-loop # ---------------------------------------------------- Composer -------------------------------------------------------- @@ -125,7 +123,7 @@ RUN php-fpm -t # ---------------------------------------------------- HEALTH ---------------------------------------------------------- -HEALTHCHECK CMD ["healthcheck-liveness"] +HEALTHCHECK CMD ["healthcheck-fpm"] # -------------------------------------------------- ENTRYPOINT -------------------------------------------------------- @@ -172,9 +170,6 @@ USER root COPY docker/*-prod /usr/local/bin/ RUN chmod +x /usr/local/bin/*-prod && pecl uninstall xdebug -# Copy PHP Production Configuration -COPY docker/php/prod-* $PHP_INI_DIR/conf.d/ - USER www-data # ----------------------------------------------- Production Config ----------------------------------------------------- @@ -187,7 +182,9 @@ COPY --chown=www-data:www-data $APP_BASE_DIR/ . ## Run Composer Install again ## ( this time to run post-install scripts, autoloader, and post-autoload scripts using one command ) -RUN post-build-base && post-build-prod +RUN composer install --optimize-autoloader --apcu-autoloader --no-dev -n --no-progress && \ + composer check-platform-reqs && \ + post-build-base && post-build-prod ENTRYPOINT ["entrypoint-prod"] CMD ["php-fpm"] @@ -207,7 +204,7 @@ ENV APP_DEBUG 1 USER root # For Composer Installs -RUN apk --no-cache add git openssh; \ +RUN apk --no-cache add git openssh bash; \ # Enable Xdebug docker-php-ext-enable xdebug @@ -219,13 +216,13 @@ ENV XDEBUG_CLIENT_HOST="host.docker.internal" # ---------------------------------------------------- Scripts --------------------------------------------------------- # Copy Dev Scripts -COPY docker/*-dev /usr/local/bin/ -RUN chmod +x /usr/local/bin/*-dev; \ -# ------------------------------------------------------ PHP ----------------------------------------------------------- - -mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" - COPY docker/php/dev-* $PHP_INI_DIR/conf.d/ +COPY docker/entrypoint/*-dev docker/post-build/*-dev docker/pre-run/*-dev \ + # to + /usr/local/bin/ + +RUN chmod +x /usr/local/bin/*-dev; \ + mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" USER www-data # ------------------------------------------------- Entry Point -------------------------------------------------------- diff --git a/docker-compose.yml b/docker-compose.yml index f952681..b495d44 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,5 +34,4 @@ services: volumes: - ${APP_BASE_DIR-.}/public:/app/public depends_on: - app: - condition: service_healthy \ No newline at end of file + - app \ No newline at end of file diff --git a/docker/entrypoint-base b/docker/entrypoint/entrypoint-base similarity index 100% rename from docker/entrypoint-base rename to docker/entrypoint/entrypoint-base diff --git a/docker/entrypoint-dev b/docker/entrypoint/entrypoint-dev similarity index 100% rename from docker/entrypoint-dev rename to docker/entrypoint/entrypoint-dev diff --git a/docker/entrypoint-prod b/docker/entrypoint/entrypoint-prod similarity index 100% rename from docker/entrypoint-prod rename to docker/entrypoint/entrypoint-prod diff --git a/docker/healthcheck-fpm b/docker/fpm/healthcheck-fpm similarity index 100% rename from docker/healthcheck-fpm rename to docker/fpm/healthcheck-fpm diff --git a/docker/healthcheck-liveness b/docker/healthcheck-liveness deleted file mode 100644 index 7d70d55..0000000 --- a/docker/healthcheck-liveness +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -eu - -# ---------------------------------------------------------------------------------------------------------------------- - -healthcheck-fpm \ No newline at end of file diff --git a/docker/post-build-prod b/docker/post-build-prod deleted file mode 100644 index 4e4a6bf..0000000 --- a/docker/post-build-prod +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -eu -# Put Custom Ad-hoc scripts after build. Like framework specific checks, etc. - -echo "► Running Composer Install..." -composer install --optimize-autoloader --apcu-autoloader --no-dev -n --no-progress - -echo "► Checking Platform Requirements" -composer check-platform-reqs \ No newline at end of file diff --git a/docker/post-build-base b/docker/post-build/post-build-base similarity index 100% rename from docker/post-build-base rename to docker/post-build/post-build-base diff --git a/docker/post-build-dev b/docker/post-build/post-build-dev similarity index 100% rename from docker/post-build-dev rename to docker/post-build/post-build-dev diff --git a/docker/post-build/post-build-prod b/docker/post-build/post-build-prod new file mode 100644 index 0000000..4a4048b --- /dev/null +++ b/docker/post-build/post-build-prod @@ -0,0 +1,3 @@ +#!/bin/sh +set -eu +# Put Custom Ad-hoc scripts after build. Like framework specific checks, etc. \ No newline at end of file diff --git a/docker/pre-run-base b/docker/pre-run/pre-run-base similarity index 100% rename from docker/pre-run-base rename to docker/pre-run/pre-run-base diff --git a/docker/pre-run-dev b/docker/pre-run/pre-run-dev similarity index 100% rename from docker/pre-run-dev rename to docker/pre-run/pre-run-dev diff --git a/docker/pre-run-prod b/docker/pre-run/pre-run-prod similarity index 82% rename from docker/pre-run-prod rename to docker/pre-run/pre-run-prod index 48f78e7..9835445 100644 --- a/docker/pre-run-prod +++ b/docker/pre-run/pre-run-prod @@ -20,5 +20,5 @@ set -e # Put Custom Ad-hoc scripts below: ## Run Envsubst on .env to expand embedded Env Variables -echo "► Expanding Dotenv files with Environment Variables..." -for f in $(find . -name ".env*"); do cat $f | envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" > "$f.tmp"; mv "$f.tmp" "$f"; done +#echo "► Expanding Dotenv files with Environment Variables..." +#for f in $(find . -name ".env*"); do cat $f | envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" > "$f.tmp"; mv "$f.tmp" "$f"; done