diff --git a/src/Handler.php b/src/Handler.php index 89fd8b08cc45b35f04272a364e6e4b0820b486f5..20b180db6121e6fc65e6894a8116b6d88b33ceaf 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -221,6 +221,9 @@ class Handler extends BaseHandler { 'enable' => $this->env->receiveGlobal('UNLIGHTHOUSE', 'Unlighthouse', '0'), 'urlprefix' => '', ], + 'invoiceninja' => [ + 'enable' => 0, + ], ]; } @@ -248,6 +251,7 @@ class Handler extends BaseHandler { '$SSH_AUTH_SOCK'; } $this->config->setValue('projectroot', $projectRoot, FALSE); + $this->config->setValue('projectrootfiles', $projectRoot, FALSE); $this->config->setValue('projectdomain', str_replace('_', '-', $this->config->readValue('projectname')) . '.' . $traefik['domain'], FALSE); $this->config->setValue('projectprotocol', 'http' . ($traefik['usessl'] ? 's' : ''), FALSE); $this->config->setValue('socketprotocol', 'ws' . ($traefik['usessl'] ? 's' : ''), FALSE); @@ -514,6 +518,11 @@ class Handler extends BaseHandler { // Ignore some Unlighthouse directories. $this->gitIgnore('tests/unlighthouse'); + if ($this->config->readValue(['invoiceninja', 'enable'])) { + // Ignore Invoice Ninja directory. + $this->gitIgnore('/in/'); + } + if (getenv('LAKEDROPS_BUILD_NG') !== 'yes') { $this->updateTraefik(); } @@ -633,6 +642,10 @@ class Handler extends BaseHandler { 'mailpitout.yml' => [ 'dest' => $projectRoot . '/tests', ], + 'in-vhost.conf' => [ + 'dest' => $projectRoot . '/config', + 'condition' => $this->config->readValue(['invoiceninja', 'enable']), + ], ]; $files['cypress.config.js'] = [ 'source' => 'tests/', diff --git a/templates/docker-compose.yml.twig b/templates/docker-compose.yml.twig index d65e906f6644962e739d0760fe63f098ac5f3441..00d55a1f27f217de8cd090cec49d19f46211ac0e 100644 --- a/templates/docker-compose.yml.twig +++ b/templates/docker-compose.yml.twig @@ -634,3 +634,106 @@ services: traefik.http.routers.unlighthouse-{{ projectname }}.tls.certresolver: lakedrops {% endif %} {% endif %} +{% if invoiceninja.enable|default(0) %} + + in-db: + image: 'mysql:5' + environment: + - APP_ENV=production + - 'APP_URL=https://invoice-{{ projectdomain }}' + - 'APP_KEY={{ invoiceninja.api_key }}' + - APP_DEBUG=false + - REQUIRE_HTTPS=false + - PHANTOMJS_PDF_GENERATION=false + - PDF_GENERATOR=snappdf + - QUEUE_CONNECTION=database + - 'TRUSTED_PROXIES=*' + - IS_DOCKER=true + - DB_HOST=in-db + - DB_PORT=3306 + - DB_DATABASE=ninja + - DB_USERNAME=ninja + - DB_PASSWORD=ninja + - IN_USER_EMAIL={{ invoiceninja.admin_name }} + - IN_PASSWORD={{ invoiceninja.admin_pass }} + - MAIL_MAILER=smtp + - MAIL_HOST={{ invoiceninja.mail.host }} + - MAIL_PORT={{ invoiceninja.mail.port }} + - MAIL_USERNAME={{ invoiceninja.mail.user }} + - 'MAIL_PASSWORD={{ invoiceninja.mail.pass }}' + - MAIL_ENCRYPTION={{ invoiceninja.mail.security }} + - MAIL_FROM_ADDRESS={{ invoiceninja.mail.user }} + - "MAIL_FROM_NAME='{{ invoiceninja.mail.fromname }}'" + - MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword + - MYSQL_USER=ninja + - MYSQL_PASSWORD=ninja + - MYSQL_DATABASE=ninja + volumes: + - '/etc/timezone:/etc/timezone:ro' + - '/etc/localtime:/etc/localtime:ro' + - '{{ projectrootfiles }}/in/mysql/data:/var/lib/mysql:rw,delegated' + in-app: + # After first startup, call "sudo chown -R 1500:1500 app" and start again. + image: 'invoiceninja/invoiceninja:5' + depends_on: + - in-db + environment: + - APP_ENV=production + - 'APP_URL=https://invoice-{{ projectdomain }}' + - 'APP_KEY={{ invoiceninja.api_key }}' + - APP_DEBUG=false + - REQUIRE_HTTPS=false + - PHANTOMJS_PDF_GENERATION=false + - PDF_GENERATOR=snappdf + - QUEUE_CONNECTION=database + - 'TRUSTED_PROXIES=*' + - IS_DOCKER=true + - DB_HOST=in-db + - DB_PORT=3306 + - DB_DATABASE=ninja + - DB_USERNAME=ninja + - DB_PASSWORD=ninja + - IN_USER_EMAIL={{ invoiceninja.admin_name }} + - IN_PASSWORD={{ invoiceninja.admin_pass }} + - MAIL_MAILER=smtp + - MAIL_HOST={{ invoiceninja.mail.host }} + - MAIL_PORT={{ invoiceninja.mail.port }} + - MAIL_USERNAME={{ invoiceninja.mail.user }} + - 'MAIL_PASSWORD={{ invoiceninja.mail.pass }}' + - MAIL_ENCRYPTION={{ invoiceninja.mail.security }} + - MAIL_FROM_ADDRESS={{ invoiceninja.mail.user }} + - "MAIL_FROM_NAME='{{ invoiceninja.mail.fromname }}'" + - MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword + - MYSQL_USER=ninja + - MYSQL_PASSWORD=ninja + - MYSQL_DATABASE=ninja + volumes: + - '/etc/timezone:/etc/timezone:ro' + - '/etc/localtime:/etc/localtime:ro' + - '{{ projectrootfiles }}/in/app/public:/var/www/app/public:rw,delegated' + - '{{ projectrootfiles }}/in/app/storage:/var/www/app/storage:rw,delegated' + in-web: + image: nginx + networks: + - traefik-public + - default + depends_on: + - in-app + volumes: + - '/etc/timezone:/etc/timezone:ro' + - '/etc/localtime:/etc/localtime:ro' + - '{{ projectroot }}/config/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro' + - '{{ projectrootfiles }}/in/app/public:/var/www/app/public:ro' + labels: + traefik.enable: 'true' + traefik.docker.network: traefik-public +{% if basicauth.enable %} + traefik.http.middlewares.invoice_ninja-{{ projectname }}-auth.basicauth.users: {{ basicauth.code }} +{% endif %} + 'traefik.http.services.invoice_ninja{{ projectname }}.loadbalancer.server.port': 80 + 'traefik.http.routers.invoice_ninja{{ projectname }}.rule': Host(`invoice-{{ projectdomain }}`) +{% if drupal.live|default(0) or traefik.usessl %} + 'traefik.http.routers.invoice_ninja{{ projectname }}.tls': 'true' + 'traefik.http.routers.invoice_ninja{{ projectname }}.tls.certresolver': lakedrops +{% endif %} +{% endif %} diff --git a/templates/in-vhost.conf.twig b/templates/in-vhost.conf.twig new file mode 100644 index 0000000000000000000000000000000000000000..e99b6fd72bc20cf68e66d208d37899021d3df15b --- /dev/null +++ b/templates/in-vhost.conf.twig @@ -0,0 +1,27 @@ +server { + listen 80 default_server; + server_name _; + + client_max_body_size 100M; + + root /var/www/app/public/; + index index.php; + + 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; } + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass in-app:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_intercept_errors off; + fastcgi_buffer_size 16k; + fastcgi_buffers 4 16k; + } +}