diff --git a/Dockerfile b/Dockerfile index 4f9658e9..a073e2e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,49 +1,40 @@ -FROM php:7.4-fpm-alpine +FROM php:7.4-fpm +# Arguments defined in docker-compose.yml +ARG user +ARG uid + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + git \ + curl \ + libpng-dev \ + libonig-dev \ + libxml2-dev \ + zip \ + unzip \ + libzip-dev \ + libmagickwand-dev \ + mariadb-client + +# Clear cache +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + +RUN pecl install imagick \ + && docker-php-ext-enable imagick + +# Install PHP extensions +RUN docker-php-ext-install pdo_mysql mbstring zip exif pcntl bcmath gd + +# Get latest Composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer + +# Create system user to run Composer and Artisan Commands +RUN useradd -G www-data,root -u $uid -d /home/$user $user +RUN mkdir -p /home/$user/.composer && \ + chown -R $user:$user /home/$user + +# Set working directory WORKDIR /var/www -RUN apk add --no-cache \ - $PHPIZE_DEPS \ - freetype-dev \ - git \ - zip \ - libzip-dev \ - php7-bcmath \ - curl \ - unzip \ - libjpeg-turbo-dev \ - libpng-dev \ - libxml2-dev \ - mariadb-client \ - sqlite \ - php7-json \ - php7-openssl \ - php7-pdo \ - php7-pdo_mysql \ - php7-session \ - php7-simplexml \ - php7-tokenizer \ - php7-xml \ - imagemagick \ - imagemagick-libs \ - imagemagick-dev \ - php7-imagick \ - php7-pcntl \ - --repository http://dl-cdn.alpinelinux.org/alpine/v3.13/community/ gnu-libiconv=1.15-r3 - -ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php - -RUN printf "\n" | pecl install \ - imagick && \ - docker-php-ext-enable --ini-name 20-imagick.ini imagick - -RUN docker-php-ext-configure zip -RUN docker-php-ext-install zip -RUN docker-php-ext-install iconv pdo pdo_mysql bcmath pcntl exif -RUN docker-php-ext-configure gd --with-jpeg --with-freetype -RUN docker-php-ext-install gd - -RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ - && php composer-setup.php \ - && php -r "unlink('composer-setup.php');" \ - && mv composer.phar /usr/bin/composer +USER $user diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 555c5952..bd849db8 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -27,17 +27,19 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { - $schedule->command('check:invoices:status') + if (\Storage::disk('local')->has('database_created')) { + $schedule->command('check:invoices:status') ->daily(); - $schedule->command('check:estimates:status') + $schedule->command('check:estimates:status') ->daily(); - $recurringInvoices = RecurringInvoice::where('status', 'ACTIVE')->get(); - foreach ($recurringInvoices as $recurringInvoice) { - $schedule->call(function () use ($recurringInvoice) { - $recurringInvoice->generateInvoice(); - })->cron($recurringInvoice->frequency); + $recurringInvoices = RecurringInvoice::where('status', 'ACTIVE')->get(); + foreach ($recurringInvoices as $recurringInvoice) { + $schedule->call(function () use ($recurringInvoice) { + $recurringInvoice->generateInvoice(); + })->cron($recurringInvoice->frequency); + } } } diff --git a/docker-compose.yml b/docker-compose.yml index c7c4ad9a..0c7cdc20 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.7' +version: '3' services: app: @@ -39,7 +39,7 @@ services: image: nginx:1.17-alpine restart: unless-stopped ports: - - 8080:80 + - 80:80 volumes: - ./:/var/www - ./docker-compose/nginx:/etc/nginx/conf.d/