Skip to content

Commit

Permalink
Merge pull request dbarzin#626 from dbarzin/dev
Browse files Browse the repository at this point in the history
work on docker
  • Loading branch information
dbarzin authored Feb 7, 2024
2 parents c52d169 + 37a7015 commit 0b63cb3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 46 deletions.
78 changes: 35 additions & 43 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 && \
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions docker/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b63cb3

Please sign in to comment.