Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

work on Docker #611

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .env.sqlite
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
APP_NAME=Mercator
APP_ENV=local
APP_KEY=base64:8G7TpThygUJfQe6zFaijVOYW7+Wk5faxHpu5V4DiUP0=
APP_DEBUG=true
APP_URL=http://localhost:8000
SERVER_NAME="127.0.0.1 localhost"

LOG_CHANNEL=stack

# LDAP_URL=ldaps://srv16ad1.hvea.healthnet.lu
# LDAP_DOMAIN=hvea.healthnet.lu
# LDAP_CERT=/etc/apache2/keys/CHEM_ROOT_CA.cer

# Database connexion
DB_CONNECTION=sqlite
DB_DATABASE=/var/www/mercator/sql/db.sqlite

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_ALERT=didier

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
37 changes: 20 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
FROM php:8.3-fpm-alpine3.19

# apparently you cannot pass both env variables
# and .env file
RUN mkdir -p /var/www/mercator/sql
ENV DB_CONNECTION=sqlite
ENV DB_DATABASE=/var/www/mercator/sql/db.sqlite
ENV SERVER_NAME="127.0.0.1 localhost"

# system deps
RUN apk update && apk add curl nano bash ssmtp graphviz fontconfig ttf-freefont ca-certificates sqlite sqlite-dev nginx gettext supervisor
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
Expand All @@ -34,34 +27,44 @@ RUN apk add php-zip \
libpng \
libpng-dev

# Install extensions
RUN docker-php-ext-install ldap gd zip
# Install PHP extensions
RUN docker-php-ext-install gd zip ldap

# Install composer
RUN curl -sS https://getcomposer.org/installer | php \
&& chmod +x composer.phar && mv composer.phar /usr/local/bin/composer

# Copy sources
COPY . /var/www/mercator
WORKDIR /var/www/mercator

# Add mercator:www user
RUN addgroup --g 1000 -S www && \
adduser -u 1000 -S mercator -G www && \
chown -R mercator:www /var/www /var/lib/nginx /var/log/nginx /etc/nginx/http.d

# Clone sources from Github
WORKDIR /var/www/
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
RUN chown -R mercator:www /etc/nginx/http.d/default.conf
RUN chown -R mercator:www /etc/supervisord.conf

# change owner
RUN chown -R mercator:www /var/www/mercator

# Now work with Mercator user
USER mercator:www

# Set environment variables
cp .env.sqlite .env

# Run composer
RUN composer -n update

# Publish Laravel Vendor resources
RUN php artisan vendor:publish --all
# RUN php artisan vendor:publish --all

# Create database folder
RUN mkdir sql

EXPOSE 8000

Expand Down
5 changes: 3 additions & 2 deletions docker/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ nodaemon=true

[program:migrate]
command=/bin/sh -c '
cd /var/www/mercator;
if [ ! -s ${DB_DATABASE} ];
then
php artisan migrate --seed --force;
php artisan migrate --seed --force --path=database/migrations;
else
php artisan migrate --force;
php artisan migrate --force --path=database/migrations;
fi;
touch /tmp/migrated'
autorestart=false
Expand Down
Loading