mirror of
https://github.com/invoiceninja/dockerfiles.git
synced 2025-12-31 19:47:25 +01:00
- make it possible to run a custom CMD
- rename volume according to their origin - Add arguments for required, suggested and extra php-modules
This commit is contained in:
39
debian/Dockerfile
vendored
39
debian/Dockerfile
vendored
@@ -1,6 +1,9 @@
|
||||
FROM php:8.3-fpm AS base
|
||||
|
||||
ARG saxon=12.5.0
|
||||
ARG php_require="bcmath gd pdo_mysql zip"
|
||||
ARG php_suggest="exif imagick intl pcntl soap"
|
||||
ARG php_suggest_debian="saxon-12.5.0"
|
||||
ARG php_extra="opcache"
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
@@ -53,22 +56,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Required PHP extensions.
|
||||
RUN ( curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - || echo 'return 1' ) | sh -s \
|
||||
bcmath \
|
||||
exif \
|
||||
gd \
|
||||
gmp \
|
||||
imagick \
|
||||
intl \
|
||||
mysqli \
|
||||
opcache \
|
||||
pcntl \
|
||||
pdo_mysql \
|
||||
redis \
|
||||
saxon-${saxon} \
|
||||
soap \
|
||||
zip \
|
||||
@composer
|
||||
RUN if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
|
||||
( curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - || echo 'return 1' ) | sh -s \
|
||||
${php_require} \
|
||||
${php_suggest} \
|
||||
${php_suggest_debian} \
|
||||
${php_extra} \
|
||||
@composer; \
|
||||
elif [ "$(dpkg --print-architecture)" = "arm64" ]; then \
|
||||
( curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - || echo 'return 1' ) | sh -s \
|
||||
${php_require} \
|
||||
${php_suggest} \
|
||||
${php_extra} \
|
||||
@composer; \
|
||||
fi
|
||||
|
||||
# Configure PHP
|
||||
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
|
||||
@@ -84,8 +85,8 @@ WORKDIR /var/www/html
|
||||
RUN curl -s "https://api.github.com/repos/invoiceninja/invoiceninja/releases/latest" | \
|
||||
grep -o '"browser_download_url": "[^"]*invoiceninja.tar"' | \
|
||||
cut -d '"' -f 4 | \
|
||||
xargs curl -L | \
|
||||
tar -oxvz -C /var/www/html \
|
||||
xargs curl -sL | \
|
||||
tar -oxz -C /var/www/html \
|
||||
&& cp /var/www/html/resources/views/react/index.blade.php /var/www/html/public/index.html \
|
||||
# File permissions
|
||||
&& find /var/www/html/ -type f -exec chmod 644 {} \; \
|
||||
|
||||
13
debian/docker-compose.yml
vendored
13
debian/docker-compose.yml
vendored
@@ -17,9 +17,9 @@ services:
|
||||
- ./php/php.ini:/usr/local/etc/php/conf.d/zzz-php.ini:ro
|
||||
- ./php/php-fpm.conf:/usr/local/etc/php-fpm.d/zzz-php-fpm.conf:ro
|
||||
- ./supervisor/supervisord.conf:/etc/supervisor/conf.d/supervisord.conf:ro
|
||||
- app_storage:/var/www/html/storage
|
||||
- app_cache:/var/www/html/bootstrap/cache
|
||||
- image_public:/var/www/html/public
|
||||
- app_public:/var/www/html/public
|
||||
- app_storage:/var/www/html/storage
|
||||
networks:
|
||||
- app-network
|
||||
depends_on:
|
||||
@@ -36,6 +36,7 @@ services:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./nginx:/etc/nginx/conf.d:ro
|
||||
- app_public:/var/www/html/public:ro
|
||||
- app_storage:/var/www/html/storage:ro
|
||||
- image_public:/var/www/html/public:ro
|
||||
networks:
|
||||
@@ -84,13 +85,13 @@ networks:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
app_storage:
|
||||
driver: local
|
||||
app_cache:
|
||||
driver: local
|
||||
app_public:
|
||||
driver: local
|
||||
app_storage:
|
||||
driver: local
|
||||
mysql_data:
|
||||
driver: local
|
||||
redis_data:
|
||||
driver: local
|
||||
image_public:
|
||||
driver: local
|
||||
|
||||
78
debian/scripts/init.sh
vendored
78
debian/scripts/init.sh
vendored
@@ -29,52 +29,52 @@ docker_process_init_files() {
|
||||
done
|
||||
}
|
||||
|
||||
# Workaround for application updates
|
||||
if [ "$(ls -A /tmp/public)" ]; then
|
||||
echo "Updating public folder..."
|
||||
rm -rf /var/www/html/public/* \
|
||||
/var/www/html/public/.htaccess \
|
||||
/var/www/html/public/.well-known
|
||||
mv /tmp/public/* \
|
||||
/tmp/public/.htaccess \
|
||||
/tmp/public/.well-known \
|
||||
/var/www/html/public/
|
||||
else
|
||||
if [ "$*" = 'supervisord -n -c /etc/supervisor/conf.d/supervisord.conf' ]; then
|
||||
# Workaround for application updates
|
||||
if [ "$(ls -A /tmp/public)" ]; then
|
||||
echo "Updating public folder..."
|
||||
rm -rf /var/www/html/public/.htaccess \
|
||||
/var/www/html/public/.well-known \
|
||||
/var/www/html/public/*
|
||||
mv /tmp/public/* \
|
||||
/tmp/public/.htaccess \
|
||||
/tmp/public/.well-known \
|
||||
/var/www/html/public/
|
||||
fi
|
||||
echo "Public Folder is up to date"
|
||||
fi
|
||||
|
||||
# Ensure owner, file and directory permissions are correct
|
||||
chown -R www-data:www-data \
|
||||
/var/www/html/storage \
|
||||
/var/www/html/public
|
||||
find /var/www/html/storage \
|
||||
/var/www/html/public \
|
||||
# Ensure owner, file and directory permissions are correct
|
||||
chown -R www-data:www-data \
|
||||
/var/www/html/public \
|
||||
/var/www/html/storage
|
||||
find /var/www/html/public \
|
||||
/var/www/html/storage \
|
||||
-type f -exec chmod 644 {} \;
|
||||
find /var/www/html/storage \
|
||||
/var/www/html/public \
|
||||
find /var/www/html/public \
|
||||
/var/www/html/storage \
|
||||
-type d -exec chmod 755 {} \;
|
||||
|
||||
# Clear and cache config in production
|
||||
if [ "$APP_ENV" = "production" ]; then
|
||||
gosu www-data php artisan optimize
|
||||
gosu www-data php artisan package:discover
|
||||
gosu www-data php artisan migrate --force
|
||||
# Clear and cache config in production
|
||||
if [ "$APP_ENV" = "production" ]; then
|
||||
gosu www-data php artisan optimize
|
||||
gosu www-data php artisan package:discover
|
||||
gosu www-data php artisan migrate --force
|
||||
|
||||
# If first IN run, it needs to be initialized
|
||||
echo "Checking initialization status..."
|
||||
IN_INIT=$(php artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();')
|
||||
echo "IN_INIT value: $IN_INIT"
|
||||
# If first IN run, it needs to be initialized
|
||||
echo "Checking initialization status..."
|
||||
IN_INIT=$(php artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();')
|
||||
echo "IN_INIT value: $IN_INIT"
|
||||
|
||||
if [ "$IN_INIT" = "1" ]; then
|
||||
echo "Running initialization scripts..."
|
||||
docker_process_init_files /docker-entrypoint-init.d/*
|
||||
fi
|
||||
|
||||
echo "Production setup completed"
|
||||
echo "IN_INIT value: $IN_INIT"
|
||||
|
||||
if [ "$IN_INIT" = "1" ]; then
|
||||
echo "Running initialization scripts..."
|
||||
docker_process_init_files /docker-entrypoint-init.d/*
|
||||
fi
|
||||
|
||||
echo "Production setup completed"
|
||||
echo "IN_INIT value: $IN_INIT"
|
||||
|
||||
echo "Starting supervisord..."
|
||||
fi
|
||||
|
||||
echo "Starting supervisord..."
|
||||
# Start supervisord in the foreground
|
||||
exec /usr/bin/supervisord -n -c /etc/supervisor/conf.d/supervisord.conf
|
||||
exec "$@"
|
||||
|
||||
Reference in New Issue
Block a user