diff --git a/.env.example b/.env.example index 3a57a44..17e9b86 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,6 @@ +# Container Role is used in start.sh +CONTAINER_ROLE=app + APP_NAME=Laravel APP_ENV=local APP_KEY= diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..016331c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM webdevops/php-nginx:8.2 +ENV WEB_DOCUMENT_ROOT /app/public +ENV SERVICE_NGINX_CLIENT_MAX_BODY_SIZE 100m +ENV FPM_PM_MAX_CHILDREN 20 +WORKDIR /app +RUN apt-get update && apt-get install -y \ + libjpeg62-turbo-dev \ + libpng-dev \ + libzip-dev \ + libgmp-dev \ + re2c \ + libmhash-dev \ + libmcrypt-dev \ + file \ + libxrender1 \ + libfontconfig1 \ + libfreetype6 +COPY --chown=application:application . . +RUN mv start.sh /opt/docker/provision/entrypoint.d/ +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" +COPY user.ini $PHP_INI_DIR/conf.d/ +RUN composer install +EXPOSE 80 diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..97a5e99 --- /dev/null +++ b/start.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -e + +role=${CONTAINER_ROLE:-app} +env=${APP_ENV:-production} + +echo "Running container role \"$role\" in \"$env\" environment. " + +php /app/artisan config:cache + +if [ "$role" = "app" ]; then + + if [ "$env" = "production" ]; then + php /app/artisan migrate --force + else + php /app/artisan migrate + fi + +elif [ "$role" = "queue" ]; then + + echo "Starting the queues..." + mv queue.conf /opt/docker/etc/supervisor.d/ + supervisorctl start queue-default queue-admin + supervisorctl status all + +elif [ "$role" = "schedule" ]; then + + while [ true ]; do + php /app/artisan schedule:run --verbose --no-interaction & + sleep 60 + done + +else + + echo "Could not match the container role \"$role\"" + exit 1 + +fi diff --git a/user.ini b/user.ini new file mode 100644 index 0000000..9d4e63a --- /dev/null +++ b/user.ini @@ -0,0 +1,2 @@ +post_max_size = 256M +upload_max_filesize = 128M