From 37a7015f3364491855a31c4fda17d94a41a67ebf Mon Sep 17 00:00:00 2001 From: Didier Date: Wed, 7 Feb 2024 07:44:53 +0100 Subject: [PATCH] work on docker --- Dockerfile | 78 ++++++++++++++++++----------------------- docker/supervisord.conf | 6 ++-- 2 files changed, 38 insertions(+), 46 deletions(-) diff --git a/Dockerfile b/Dockerfile index 06a41d02..07cae032 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,37 @@ FROM php:8.3-fpm-alpine3.19 -# system deps -RUN apk update && apk add git curl nano bash ssmtp graphviz fontconfig ttf-freefont ca-certificates sqlite sqlite-dev nginx gettext supervisor - -# run font cache -RUN fc-cache -f - -# php deps -RUN apk add php-zip \ - php-curl \ - php-mbstring \ - php-dom \ - php-ldap \ - php-soap \ - php-xdebug \ - php-sqlite3 \ - php-gd \ - php-xdebug \ - php-gd \ - php-pdo php-pdo_sqlite \ - php-fileinfo \ - php-simplexml php-xml php-xmlreader php-xmlwriter \ - php-tokenizer \ - libzip-dev \ - openldap-dev \ - libpng \ - libpng-dev +# Add packages +RUN apk update && \ + apk add git curl nano bash ssmtp graphviz fontconfig ttf-freefont ca-certificates sqlite sqlite-dev nginx gettext supervisor \ + php-zip \ + php-curl \ + php-mbstring \ + php-dom \ + php-ldap \ + php-soap \ + php-xdebug \ + php-sqlite3 \ + php-gd \ + php-xdebug \ + php-gd \ + php-pdo php-pdo_sqlite \ + php-fileinfo \ + php-simplexml php-xml php-xmlreader php-xmlwriter \ + php-tokenizer \ + libzip-dev \ + openldap-dev \ + libpng \ + libpng-dev # Install PHP extensions RUN docker-php-ext-install gd zip ldap +# run font cache +RUN fc-cache -f + # Install composer -RUN curl -sS https://getcomposer.org/installer | php \ - && chmod +x composer.phar && mv composer.phar /usr/local/bin/composer +RUN curl -sS https://getcomposer.org/installer | php && \ + chmod +x composer.phar && mv composer.phar /usr/local/bin/composer # Add mercator:www user RUN addgroup --g 1000 -S www && \ @@ -45,26 +44,19 @@ RUN git clone https://www.github.com/dbarzin/mercator WORKDIR /var/www/mercator # Copy config files -RUN cp docker/nginx.conf /etc/nginx/http.d/default.conf -RUN cp docker/supervisord.conf /etc/supervisord.conf - -# change owner -RUN chown -R mercator:www /var/www/mercator +RUN cp docker/nginx.conf /etc/nginx/http.d/default.conf && \ + cp docker/supervisord.conf /etc/supervisord.conf && \ + chown -R mercator:www /var/www/mercator # Now work with Mercator user USER mercator:www -# Run composer -RUN composer -n update - -# Publish Laravel Vendor resources -RUN php artisan vendor:publish --all - -# Create database folder -RUN mkdir sql +# Run composer and publish Laravel Vendor resources +RUN composer -n update && php artisan vendor:publish --all -# copy environement varaibles file -RUN cp .env.sqlite .env +# Create database folder and copy environement varaibles file +# It must be done at the end +RUN cp .env.sqlite .env && mkdir sql && touch sql/db.sqlite # Start surpervisord EXPOSE 8000 diff --git a/docker/supervisord.conf b/docker/supervisord.conf index 659141bf..a84148af 100644 --- a/docker/supervisord.conf +++ b/docker/supervisord.conf @@ -3,11 +3,11 @@ nodaemon=true [program:migrate] command=/bin/sh -c ' - if [ ! -s ${DB_DATABASE} ]; + if [ -s ${DB_DATABASE} ]; then - php artisan migrate --seed --force; - else php artisan migrate --force; + else + php artisan migrate --seed --force; fi; touch /tmp/migrated' autorestart=false