Compare commits

...

52 Commits

Author SHA1 Message Date
David Bomba
9944d43f0b Merge pull request #765 from stavros-k/patch-1
Update init.sh
2025-07-07 08:42:59 +10:00
Stavros Kois
5eefcecf47 Update init.sh
Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
2025-07-03 13:57:12 +03:00
David Bomba
f80e7f2ec3 Merge pull request #752 from benbrummer/octane
saxon defaults now to 12.5.0
2025-05-11 09:44:33 +10:00
benbrummer
f5821630fa saxon defaults now to 12.5.0
Signed-off-by: benbrummer <info@benjamin-brummer.de>
2025-05-10 10:58:40 +02:00
David Bomba
1848f11a36 Merge pull request #751 from benbrummer/octane
align octane to debian
2025-05-08 19:41:31 +10:00
Benjamin Brummer
f96d4d4aa0 image versions as ARGs 2025-05-08 06:58:11 +00:00
Benjamin Brummer
5d29d3a052 align init.sh with invoiceninja-debian 2025-05-08 06:43:50 +00:00
Benjamin Brummer
0c607953ec HEALTHCHECK for laravel 2025-05-08 06:43:23 +00:00
Benjamin Brummer
ebc6c3642a remove cache volume and healthcheck configuration 2025-05-08 06:43:03 +00:00
David Bomba
ec35498159 set conditional for chrome / chromium path 2025-03-25 12:04:11 +11:00
David Bomba
4bff59808e Merge pull request #730 from benbrummer/octane
use github latest url, tar.gz without top level repository, mbstring
2025-03-19 10:05:07 +11:00
benbrummer
217c05bd1f use github latest url, tar.gz without top level repository, mbstring
Signed-off-by: benbrummer <info@benjamin-brummer.de>
2025-03-15 07:41:00 +01:00
David Bomba
24d1f9cd2e Merge pull request #714 from turbo124/octane
Fixes for publish image regression - force 22.04
2025-01-24 16:15:58 +11:00
David Bomba
9a3603b709 Fixes for publish image regression - force 22.04 2025-01-24 16:15:09 +11:00
David Bomba
c2bf3ca8d9 Merge pull request #709 from turbo124/octane
Change context dir from ./debian to debian
2025-01-24 14:28:42 +11:00
David Bomba
1c3f96e723 Change context dir from ./debian to debian 2025-01-24 14:28:11 +11:00
David Bomba
2364f53777 Merge pull request #708 from turbo124/octane
Debug php extension installer
2025-01-24 13:57:28 +11:00
David Bomba
7bfbe9ee03 Install each extension individually to identify the root cause 2025-01-24 13:56:44 +11:00
David Bomba
afd597456f Minor fixes for build files 2025-01-24 13:36:58 +11:00
David Bomba
243f46bd23 Merge pull request #707 from turbo124/octane
Fixes for php extension installer
2025-01-24 13:35:26 +11:00
David Bomba
6dfaa3b441 Fixes for php extension installer 2025-01-24 13:34:52 +11:00
David Bomba
6d0e0648e3 Fixes for php extension installer 2025-01-24 12:58:47 +11:00
David Bomba
85979fdcf2 Require mbstring 2025-01-24 09:22:36 +11:00
David Bomba
377c068667 Merge pull request #690 from benbrummer/octane
Octane
2025-01-15 08:18:57 +11:00
benbrummer
da7f8d93b0 Merge branch 'invoiceninja:octane' into octane 2025-01-13 13:40:31 +01:00
Benjamin Brummer
1d475a5218 php.ini with frankenphp/symfony recommendations 2025-01-12 00:57:51 +00:00
Benjamin Brummer
3a8184df73 fix for initialization with opcache.preload enabled 2025-01-12 00:56:21 +00:00
Benjamin Brummer
0c796fee5f use invoiceninja.tar.gz 2025-01-12 00:54:53 +00:00
David Bomba
bc5aa2e844 Merge pull request #686 from benbrummer/frankenphp
healthcheck for scheduler and worker
2025-01-11 16:40:22 +11:00
Benjamin Brummer
295bb6268b remove moiunt for php.ini 2025-01-10 07:32:58 +00:00
Benjamin Brummer
ff636077d4 --help flag for usage instructions 2025-01-10 07:31:35 +00:00
Benjamin Brummer
247f946422 include minimal php settings in the image 2025-01-10 07:31:03 +00:00
Benjamin Brummer
4c50bbad19 H3_GENERAL_PROTOCOL_ERROR only happens on Firefox 2025-01-09 13:23:29 +00:00
Benjamin Brummer
2e22177b20 permissions are already correct in the release artifact tar/tar.gz 2025-01-09 12:43:05 +00:00
Benjamin Brummer
dfc392580e healthcheck for scheduler and worker 2025-01-09 10:15:37 +00:00
David Bomba
260980f2a3 Merge pull request #685 from benbrummer/frankenphp
https for octane
2025-01-08 13:47:46 +11:00
Benjamin Brummer
57724b7d93 Single RUN for first stage to avoid insane build times 2025-01-07 11:51:09 +00:00
Benjamin Brummer
39b6680f0b added example command for https and caddy_data volume for persistent certificates 2025-01-07 10:04:24 +00:00
David Bomba
768df3c1dd Merge pull request #682 from benbrummer/frankenphp
Cleanup
2025-01-07 13:01:02 +11:00
Benjamin Brummer
7870b345ed composer is not needed 2025-01-05 16:57:56 +00:00
Benjamin Brummer
3c6ed5cda1 remove octane installation 2025-01-04 19:41:05 +00:00
Benjamin Brummer
2f43d4b45a php.ini refactoring 2025-01-04 18:52:36 +00:00
David Bomba
a71af868d2 Add build pipe for octane 2025-01-04 19:36:30 +11:00
David Bomba
237abe4aa8 Merge pull request #678 from benbrummer/frankenphp
Frankenphp
2025-01-03 13:47:40 +11:00
Benjamin Brummer
f680c8a59a require laravel/octane 2024-12-31 17:57:54 +01:00
Benjamin Brummer
8f51f3bc51 octane and multistage 2024-12-31 17:52:48 +01:00
Benjamin Brummer
e4c26dde5d Merge branch 'frankenphp' of https://github.com/benbrummer/dockerfiles into frankenphp 2024-12-28 09:25:43 +01:00
Benjamin Brummer
9c96e9d261 make mysql and redis available/default again 2024-12-28 09:25:25 +01:00
benbrummer
e1cde6b6be Merge branch 'invoiceninja:debian' into frankenphp 2024-12-28 08:58:49 +01:00
Benjamin Brummer
068acdd097 remove nginx, php-fpm and supervisord configuration 2024-12-28 08:36:19 +01:00
Benjamin Brummer
95aec27c65 Merge init scripts 2024-12-28 08:35:19 +01:00
Benjamin Brummer
6c6950d298 frankenphp, mariadb and valkey 2024-12-28 08:33:39 +01:00
12 changed files with 250 additions and 276 deletions

View File

@@ -1,4 +1,4 @@
name: Build Debian Container Image name: Build Debian Octane Container Image
on: on:
pull_request: pull_request:
@@ -12,7 +12,7 @@ on:
jobs: jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -33,6 +33,6 @@ jobs:
context: debian context: debian
file: debian/Dockerfile file: debian/Dockerfile
load: true load: true
tags: invoiceninja/invoiceninja-debian:test tags: invoiceninja/invoiceninja-octane:test
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max

View File

@@ -7,16 +7,16 @@ on:
jobs: jobs:
docker: docker:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
strategy: strategy:
matrix: matrix:
include: include:
- image: invoiceninja/invoiceninja-debian - image: invoiceninja/invoiceninja-octane
context: ./debian context: debian
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 # Updated from v2 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0

2
debian/.env vendored
View File

@@ -57,6 +57,6 @@ NORDIGEN_SECRET_KEY=
IS_DOCKER=true IS_DOCKER=true
SCOUT_DRIVER=null SCOUT_DRIVER=null
SNAPPDF_CHROMIUM_PATH=/usr/bin/google-chrome-stable #SNAPPDF_CHROMIUM_PATH=/usr/bin/google-chrome-stable

113
debian/Dockerfile vendored
View File

@@ -1,14 +1,39 @@
FROM php:8.3-fpm AS base ARG PHP_VERSION=8.3
ARG FRANKENPHP_VERSION=1
ARG DEBIAN_VERSION=bookworm
ARG php_require="bcmath gd pdo_mysql zip" FROM dunglas/frankenphp:${FRANKENPHP_VERSION}-php${PHP_VERSION}-${DEBIAN_VERSION} AS prepare-app
ARG php_suggest="exif imagick intl pcntl soap saxon-12.5.0"
RUN curl -sL "https://github.com/invoiceninja/invoiceninja/releases/latest/download/invoiceninja.tar.gz" | \
tar -xz \
&& ln -s ./resources/views/react/index.blade.php ./public/index.html \
# Symlink
&& php artisan storage:link \
# Octane
&& php artisan octane:install --server=frankenphp
# ==================
# InvoiceNinja image
# ==================
FROM dunglas/frankenphp:${FRANKENPHP_VERSION}-php${PHP_VERSION}-${DEBIAN_VERSION}
ARG user=ninja
# PHP modules
ARG php_require="bcmath gd mbstring pdo_mysql zip"
ARG php_suggest="exif imagick intl pcntl saxon soap"
ARG php_extra="opcache" ARG php_extra="opcache"
# Create a system user UID/GID=999
RUN useradd -r ${user}
# Allow to bind to privileged ports
RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp
# Install system dependencies # Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
mariadb-client \ mariadb-client \
gpg \ gpg \
supervisor \
# Unicode support for PDF # Unicode support for PDF
fonts-noto-cjk-extra \ fonts-noto-cjk-extra \
fonts-wqy-microhei \ fonts-wqy-microhei \
@@ -16,19 +41,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
xfonts-wqy \ xfonts-wqy \
# Install google-chrome-stable(amd64)/chromium(arm64) # Install google-chrome-stable(amd64)/chromium(arm64)
&& if [ "$(dpkg --print-architecture)" = "amd64" ]; then \ && if [ "$(dpkg --print-architecture)" = "amd64" ]; then \
mkdir -p /etc/apt/keyrings \ mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | \ && curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | \
gpg --dearmor -o /etc/apt/keyrings/google.gpg \ gpg --dearmor -o /etc/apt/keyrings/google.gpg \
&& echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google.gpg] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \ && echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/google.gpg] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update \ && apt-get update \
&& apt-get install -y --no-install-recommends google-chrome-stable; \ && apt-get install -y --no-install-recommends google-chrome-stable \
&& mkdir /config/google-chrome \
&& chown ${user}: /config/google-chrome; \
elif [ "$(dpkg --print-architecture)" = "arm64" ]; then \ elif [ "$(dpkg --print-architecture)" = "arm64" ]; then \
apt-get install -y --no-install-recommends \ apt-get install -y --no-install-recommends \
chromium; \ chromium \
&& mkdir /config/chromium \
&& chown ${user}: /config/chromium; \
fi \ fi \
# Create config directory for chromium/google-chrome-stable
&& mkdir /var/www/.config \
&& chown www-data:www-data /var/www/.config \
# Cleanup # Cleanup
&& apt-get purge -y gpg \ && apt-get purge -y gpg \
&& apt-get autoremove -y \ && apt-get autoremove -y \
@@ -36,52 +62,35 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Install PHP extensions # Install 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 \ RUN install-php-extensions \
${php_require} \ ${php_require} \
${php_suggest} \ ${php_suggest} \
${php_extra} \ ${php_extra}
@composer
# Configure PHP # Configure PHP
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" RUN ln -s "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini"
# Copy scripts COPY php/php.ini /usr/local/etc/php/conf.d/invoiceninja.ini
COPY rootfs /
USER www-data # Create directory for artisan tinker (init.sh)
RUN mkdir /config/psysh \
&& chown ${user}: /config/psysh
WORKDIR /var/www/html # Change owner for caddy directories
RUN chown -R ${user}: \
/data/caddy \
/config/caddy
# Setup InvoiceNinja # InvoiceNinja
RUN curl -s "https://api.github.com/repos/invoiceninja/invoiceninja/releases/latest" | \ COPY --from=prepare-app --chown=${user}:${user} /app /app
grep -o '"browser_download_url": "[^"]*invoiceninja.tar"' | \
cut -d '"' -f 4 | \
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 {} \; \
# Directory permissions
&& find /var/www/html/ -type d -exec chmod 755 {} \; \
# Install dependencies
&& composer install --no-dev --no-scripts --no-autoloader \
&& composer dump-autoload --optimize \
&& php artisan optimize \
&& php artisan storage:link \
# Workaround for application updates
&& mv /var/www/html/public /tmp/public
USER root
# Setup supervisor
COPY supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
# Add initialization script # Add initialization script
COPY --chmod=0755 scripts/init.sh /usr/local/bin/init.sh COPY --chmod=0755 scripts/init.sh /usr/local/bin/init.sh
# Health check USER ${user}
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD php -v || exit 1 HEALTHCHECK --start-period=10s CMD curl -f http://localhost/health
ENTRYPOINT ["/usr/local/bin/init.sh"] ENTRYPOINT ["/usr/local/bin/init.sh"]
CMD ["supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
CMD ["frankenphp", "php-cli", "artisan", "octane:frankenphp"]

View File

@@ -1,47 +1,83 @@
# name: invoiceninja
x-logging: &default-logging x-logging: &default-logging
options: options:
max-size: "10m" max-size: "10m"
max-file: "3" max-file: "3"
driver: json-file driver: json-file
x-app-volumes: &volumes
volumes:
- ./.env:/app/.env
- app_storage:/app/storage
- caddy_data:/data
services: services:
app: app:
build: build:
context: . context: .
image: invoiceninja/invoiceninja-debian:${TAG:-latest} image: invoiceninja/invoiceninja-debian:${TAG:-latest}
restart: unless-stopped restart: unless-stopped
# php artisan help octane:frankenphp
command: --port=80 --workers=2 --log-level=info
# command: --host=example.com --port=443 --workers=2 --https --http-redirect --log-level=info
ports:
- "80:80" # HTTP
# - "443:443" # HTTPS
# - "443:443/udp" # HTTP/3, Works for chromium based browser, but causes H3_GENERAL_PROTOCOL_ERROR for pdf previews in Firefox
env_file: env_file:
- ./.env - ./.env
volumes: environment:
- ./.env:/var/www/html/.env LARAVEL_ROLE: app
- ./php/php.ini:/usr/local/etc/php/conf.d/zzz-php.ini:ro <<: *volumes
- ./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_cache:/var/www/html/bootstrap/cache
- app_public:/var/www/html/public
- app_storage:/var/www/html/storage
networks:
- app-network
depends_on: depends_on:
mysql: mysql:
condition: service_healthy condition: service_healthy
redis: redis:
condition: service_healthy condition: service_healthy
# mariadb:
# condition: service_healthy
# valkey:
# condition: service_healthy
logging: *default-logging
app-worker:
image: invoiceninja/invoiceninja-debian:${TAG:-latest}
restart: unless-stopped
# php artisan help queue:work
command: --verbose --sleep=3 --tries=3 --max-time=3600
deploy:
mode: replicated
replicas: 2
env_file:
- ./.env
environment:
LARAVEL_ROLE: worker
<<: *volumes
healthcheck:
test: ["CMD", "pgrep", "-f", "queue:work"]
start_period: 10s
depends_on:
app:
condition: service_healthy
logging: *default-logging logging: *default-logging
nginx: app-scheduler:
image: nginx:alpine image: invoiceninja/invoiceninja-debian:${TAG:-latest}
restart: unless-stopped restart: unless-stopped
ports: # php artisan help schedule:work
- "80:80" command: --verbose
volumes: env_file:
- ./nginx:/etc/nginx/conf.d:ro - ./.env
- app_public:/var/www/html/public:ro environment:
- app_storage:/var/www/html/storage:ro LARAVEL_ROLE: scheduler
networks: <<: *volumes
- app-network healthcheck:
test: ["CMD", "pgrep", "-f", "schedule:work"]
start_period: 10s
depends_on: depends_on:
- app app:
condition: service_healthy
logging: *default-logging logging: *default-logging
mysql: mysql:
@@ -56,8 +92,6 @@ services:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
volumes: volumes:
- mysql_data:/var/lib/mysql - mysql_data:/var/lib/mysql
networks:
- app-network
healthcheck: healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-u${MYSQL_USER}", "-p${MYSQL_PASSWORD}" ] test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-u${MYSQL_USER}", "-p${MYSQL_PASSWORD}" ]
interval: 10s interval: 10s
@@ -70,8 +104,6 @@ services:
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- redis_data:/data - redis_data:/data
networks:
- app-network
healthcheck: healthcheck:
test: [ "CMD", "redis-cli", "ping" ] test: [ "CMD", "redis-cli", "ping" ]
interval: 10s interval: 10s
@@ -79,18 +111,37 @@ services:
retries: 5 retries: 5
logging: *default-logging logging: *default-logging
networks: # mariadb:
app-network: # image: mariadb:11.4
driver: bridge # restart: unless-stopped
# env_file:
# - ./.env
# environment:
# MARIADB_DATABASE: ${DB_DATABASE}
# MARIADB_USER: ${DB_USERNAME}
# MARIADB_PASSWORD: ${DB_PASSWORD}
# MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
# volumes:
# - mariadb:/var/lib/mysql
# healthcheck:
# test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
# start_period: 60s
# logging: *default-logging
# valkey:
# image: valkey/valkey:8
# restart: unless-stopped
# volumes:
# - valkey:/data
# healthcheck:
# test: [ "CMD", "valkey-cli", "ping" ]
# start_period: 10s
# logging: *default-logging
volumes: volumes:
app_cache:
driver: local
app_public:
driver: local
app_storage: app_storage:
driver: local caddy_data:
mysql_data: mysql_data:
driver: local
redis_data: redis_data:
driver: local # mariadb:
# valkey:

View File

@@ -1,14 +0,0 @@
# https://nginx.org/en/docs/http/ngx_http_core_module.html
client_max_body_size 10M;
client_body_buffer_size 10M;
server_tokens off;
# https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html
fastcgi_buffers 32 16K;
# https://nginx.org/en/docs/http/ngx_http_gzip_module.html
gzip on;
gzip_comp_level 2;
gzip_min_length 1M;
gzip_proxied any;
gzip_types *;

View File

@@ -1,32 +0,0 @@
# https://laravel.com/docs/master/deployment#nginx
server {
listen 80 default_server;
server_name _;
root /var/www/html/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass app:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}

View File

@@ -1 +0,0 @@
pm.max_children = 10

22
debian/php/php.ini vendored
View File

@@ -1,15 +1,23 @@
[core] [core]
# https://www.php.net/manual/en/ini.core.php ; https://www.php.net/manual/en/ini.core.php
post_max_size = 10M post_max_size=10M
upload_max_filesize = 10M upload_max_filesize=10M
[opcache] [opcache]
# https://www.php.net/manual/en/opcache.installation.php#opcache.installation.recommended ; https://www.php.net/manual/en/opcache.installation.php#opcache.installation.recommended
opcache.enable_cli=1 opcache.enable_cli=1
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
[jit] [jit]
# https://wiki.php.net/rfc/jit_config_defaults ; https://wiki.php.net/rfc/jit_config_defaults
opcache.jit=tracing opcache.jit=tracing
opcache.jit_buffer_size=64M opcache.jit_buffer_size=64M
[extra]
; https://frankenphp.dev/docs/performance/#php-performance
; http://symfony.com/doc/current/performance.html
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.preload=/app/preload.php
opcache.validate_timestamps=0
realpath_cache_size = 4096K
realpath_cache_ttl = 600

View File

@@ -1,14 +0,0 @@
#!/bin/sh
php artisan db:seed --force
# Build up array of arguments...
if [ ! -z "${IN_USER_EMAIL}" ]; then
email="--email ${IN_USER_EMAIL}"
fi
if [ ! -z "${IN_PASSWORD}" ]; then
password="--password ${IN_PASSWORD}"
fi
php artisan ninja:create-account $email $password

144
debian/scripts/init.sh vendored
View File

@@ -1,81 +1,97 @@
#!/bin/sh #!/bin/sh -eu
set -e
in_log() { # Fallback to app
local type="$1" role=${LARAVEL_ROLE:-app}
shift
printf '%s [%s] [Entrypoint]: %s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$type" "$*"
}
docker_process_init_files() { # Set PDF generation browser path based on architecture
echo export SNAPPDF_CHROMIUM_PATH=/usr/bin/google-chrome-stable
local f if [ "$(dpkg --print-architecture)" = "arm64" ]; then
for f; do export SNAPPDF_CHROMIUM_PATH=/usr/bin/chromium
case "$f" in fi
*.sh)
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 # Check for default CMD, flag(s) or empty CMD
# https://github.com/docker-library/postgres/pull/452 if [ "$*" = 'frankenphp php-cli artisan octane:frankenphp' ] || [ "${1#-}" != "$1" ] || [ "$#" -eq "0" ]; then
if [ -x "$f" ]; then
in_log INFO "$0: running $f" if [ "--help" = "$1" ]; then
"$f" echo [CMD]
else echo "This image will execute specific CMDs based on the environment variable LARAVEL_ROLE"
in_log INFO "$0: sourcing $f"
. "$f"
fi
;;
*) in_log INFO "$0: ignoring $f" ;;
esac
echo echo
done echo "LARAVEL_ROLE=app: frankenphp php-cli artisan octane:frankenphp (default)"
} echo "LARAVEL_ROLE=worker: frankenphp php-cli artisan queue:work"
echo "LARAVEL_ROLE=scheduler: frankenphp php-cli artisan schedule:work"
if [ "$*" = 'supervisord -c /etc/supervisor/conf.d/supervisord.conf' ]; then echo
# Workaround for application updates echo [FLAGS]
if [ "$(ls -A /tmp/public)" ]; then echo To the CMD defined by LARAVEL_ROLE can be extended with flags for artisan commands
echo "Updating public folder..." echo
rm -rf /var/www/html/public/.htaccess \ echo Available flags can be displaced:
/var/www/html/public/.well-known \ echo docker run --rm invoiceninja/invoiceninja-debian frankenphp php-cli artisan help octane:frankenphp
/var/www/html/public/* echo docker run --rm invoiceninja/invoiceninja-debian frankenphp php-cli artisan queue:work
mv /tmp/public/* \ echo docker run --rm invoiceninja/invoiceninja-debian frankenphp php-cli artisan schedule:work
/tmp/public/.htaccess \ echo
/tmp/public/.well-known \ echo Example:
/var/www/html/public/ echo docker run -e LARAVEL_ROLE=worker invoiceninja/invoiceninja-debian --verbose --sleep=3 --tries=3 --max-time=3600
echo
echo [Deployment]
echo Docker compose is recommended
echo
echo Example:
echo https://github.com/invoiceninja/dockerfiles/blob/octane/debian/docker-compose.yml
echo
exit 0
fi fi
echo "Public Folder is up to date"
# Ensure owner, file and directory permissions are correct # Run app
chown -R www-data:www-data \ if [ "${role}" = "app" ]; then
/var/www/html/public \ cmd="frankenphp php-cli artisan octane:frankenphp"
/var/www/html/storage
find /var/www/html/public \
/var/www/html/storage \
-type f -exec chmod 644 {} \;
find /var/www/html/public \
/var/www/html/storage \
-type d -exec chmod 755 {} \;
# Clear and cache config in production # Check for required folders and create if needed, relevant for bind mounts
if [ "$APP_ENV" = "production" ]; then # It is not possible to chown, as we are not executing this script as root
runuser -u www-data -- php artisan optimize [ -d /app/storage/framework/sessions ] || mkdir -p /app/storage/framework/sessions
runuser -u www-data -- php artisan package:discover [ -d /app/storage/framework/views ] || mkdir -p /app/storage/framework/views
runuser -u www-data -- php artisan migrate --force [ -d /app/storage/framework/cache ] || mkdir -p /app/storage/framework/cache
if [ "$APP_ENV" = "production" ]; then
frankenphp php-cli artisan optimize
fi
frankenphp php-cli artisan package:discover
# Run migrations (if any)
frankenphp php-cli artisan migrate --force
# If first IN run, it needs to be initialized # If first IN run, it needs to be initialized
echo "Checking initialization status..." if [ "$(frankenphp php-cli artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();')" = "1" ]; then
IN_INIT=$(php artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();') echo "Running initialization..."
echo "IN_INIT value: $IN_INIT"
if [ "$IN_INIT" = "1" ]; then frankenphp php-cli artisan db:seed --force
echo "Running initialization scripts..."
docker_process_init_files /docker-entrypoint-init.d/* if [ -n "${IN_USER_EMAIL}" ] && [ -n "${IN_PASSWORD}" ]; then
frankenphp php-cli artisan ninja:create-account --email "${IN_USER_EMAIL}" --password "${IN_PASSWORD}"
else
echo "Initialization failed - Set IN_USER_EMAIL and IN_PASSWORD in .env"
exit 1
fi
fi fi
echo "Production setup completed" echo "Production setup completed"
echo "IN_INIT value: $IN_INIT" # Run worker
elif [ "${role}" = "worker" ]; then
cmd="frankenphp php-cli artisan queue:work"
# Run scheduler
elif [ "${role}" = "scheduler" ]; then
cmd="frankenphp php-cli artisan schedule:work"
# Invalid role
else
echo "Invalid role: ${role}"
exit 1
fi fi
echo "Starting supervisord..." # Append flag(s) to role cmd
if [ "${1#-}" != "$1" ]; then
set -- ${cmd} "$@"
else
set -- ${cmd}
fi
fi fi
exec "$@" exec "$@"

View File

@@ -1,49 +0,0 @@
[unix_http_server]
file=/var/run/supervisor.sock
chmod=0700
[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock
[program:php-fpm]
command=/usr/local/sbin/php-fpm -F
autostart=true
autorestart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:queue-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/artisan queue:work --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=2
environment=HOME="/var/www"
stdout_logfile=/var/log/php-worker.log
stderr_logfile=/var/log/php-worker.err.log
stopwaitsecs=3600
[program:scheduler]
command=/bin/sh -c "while [ true ]; do (php /var/www/html/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
autostart=true
autorestart=true
user=www-data
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0