Comments (10)
For those who might care this is how I got it working on my setup where the only part of the image I wanted was the ninja invoice as I am running nginx and mysql on the host in front of multiple docker images and other sites.
nginx settings:
# Redirect to SSL
server {
listen _YOUR_SERVER_IP_:80;
server_name _YOUR_DOMAIN_NAME_;
return 301 https://_YOUR_DOMAIN_NAME_$request_uri;
}
# SSL Server
server {
listen _YOUR_SERVER_IP_:443 ssl http2;
server_name _YOUR_DOMAIN_NAME_;
# Assuming your using Lets-Encrypt for your server SSL
ssl_certificate /etc/letsencrypt/live/_SERVER_NAME_/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/_SERVER_NAME_/privkey.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1h;
ssl_buffer_size 1400;
error_page 502 /errors/502.html;
location ~ /\.git {
return 404;
}
location ~* /storage/.*\.php$ {
return 503;
}
# DO NOT CHANGE THIS "ROOT" PATH, IT MUST MATCH THE INTERNAL FIXED DOCKER INVOICE NINJA WEB PATH.
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$ {
# 9000 is the default port, but if you run php-fpm on your server this port should be
# changed to match the port you want to use via the docker-compose.yml port
fastcgi_pass localhost:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
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;
}
}
Docker-compose.yml
version: '3.7'
services:
app:
image: invoiceninja/invoiceninja:latest
env_file: env
restart: unless-stopped
volumes:
- /var/www/app/public:/var/www/app/public:rw,delegated
- /var/www/app/storage:/var/www/app/storage:rw,delegated
- ./config/php/php.ini:/usr/local/etc/php/php.ini
- ./config/php/php-cli.ini:/usr/local/etc/php/php-cli.ini
ports:
- 9000:9000
Please note a couple things:
- If is CRITICAL that your public directory be at
/var/www/app/public
Nginx needs to have the EXACT same path as PHP uses. At this point you can't change the dockers public directory. So this is a fixed value!!! This public directory will be automatically seeded/filled by the invoice ninja when it starts up so that nginx can serve static files like the css/js/images. - it is also critical that the ports match, so if you changed the docker file to
- 9005:9000
then in the Nginx configuration you need to use port 9005. - I also copied the two php config files from this repo and dropped them into ./config/php in this docker app folder.
- Port 9000 is a FastCGI/FPM port, it is NOT a browsable/http port, this is why you have to have Nginx in front of it and communicating with it using its own FastCGI/FPM protocol.
Now in my case, I actually created a symlink at /var/www/app/public
to point to where I actually store my public files as I prefer to keep them with the app docker folder so the storage&public files actually live physically else where. Nginx must still be pointed and be able to see the files in that folder /var/www/app/public
(hence using a symlink here) or it can't pass on the php requests properly or serve any of the static files..
from dockerfiles.
I can confirm that I'm experiencing similar issues. The Docker log indicates that the expected port is not being exposed as per the documentation. Here is the Docker log output for reference:
[Entrypoint]: Initialising Invoice Ninja...
INFO Configuration cached successfully.
INFO Caching the framework bootstrap files.
config ........................................................... 60ms DONE
routes ........................................................... 82ms DONE
INFO Discovering packages.
imdhemy/laravel-purchases ............................................. DONE
intervention/image .................................................... DONE
invoiceninja/inspector ................................................ DONE
laravel/slack-notification-channel .................................... DONE
laravel/socialite ..................................................... DONE
laravel/tinker ........................................................ DONE
laravel/ui ............................................................ DONE
livewire/livewire ..................................................... DONE
nesbot/carbon ......................................................... DONE
nunomaduro/termwind ................................................... DONE
nwidart/laravel-modules ............................................... DONE
sentry/sentry-laravel ................................................. DONE
socialiteproviders/manager ............................................ DONE
spatie/laravel-data ................................................... DONE
turbo124/beacon ....................................................... DONE
webpatser/laravel-countries ........................................... DONE
In Connection.php line 822:
SQLSTATE[HY000] [2002] No such file or directory (Connection: mysql, SQL: s
elect * from information_schema.tables where table_schema = ninja and table
_name = accounts and table_type = 'BASE TABLE')
In Connector.php line 65:
SQLSTATE[HY000] [2002] No such file or directory
It appears that the documentation might not accurately reflect the current behavior of the Docker image, particularly with respect to the ports being exposed and the PHP version specified. Any guidance on this would be helpful.
from dockerfiles.
I speculate the port 80 thing might be before the docker image shifted to serving PHP-FPM (or equivalent) since so far as I can tell the current docker images only serve PHP-FPM services (and on port 9000), hence needing another nginx in-front of it to serve the other content too (non php files, and manage the php content sent to the PHP-FPM in the docker image).
from dockerfiles.
I just followed the instructions in the https://github.com/invoiceninja/dockerfiles page using docker compose, and I am getting the same errors shown here when I checked the logs for the app container.
May I know what I need to update in order to get the application running? Thank you.
from dockerfiles.
From what I've seen, the exposed port 9000 service is PHP-FPM or roughly equivalent. So you will need to stick something in front of it (like nginx, but others can work) to handle incoming HTTP(S) traffic, and then be configured to use the invoiceNinja container for PHP-FPM functionality for the tool. In my case I added a side-car/secondary container for nginx to do this.
Really aggravating that the documentation is so egregiously out of date with the actual behaviour of the container. It's not even a lot of work to change that documentation (which frankly isn't my job). So yeah, we (myself + others) have to resort to cobbling it together ourselves with half-assed and incomplete documentation.
from dockerfiles.
Thanks for the prompt response, I greatly appreciate it. Unfortunately, I am not a very technical person so this is a little hard for me to follow. Do you think you can give me a bit more guidance on how I can get it running?
I am trying to host Invoice Ninja from my Synology using docker, and I am using Synology's built-in nginx reverse proxy.
In my docker-compose.yml
which I have taken from the official docs, I have the following:
services:
server:
image: nginx
restart: always
env_file: env
volumes:
# Vhost configuration
#- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com
- ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro
- ./docker/app/public:/var/www/app/public:ro
depends_on:
- app
# Run webserver nginx on port 80
# Feel free to modify depending what port is already occupied
ports:
- "8001:80"
# - "443:443"
networks:
- invoiceninja
# extra_hosts:
# - "in5.localhost:192.168.0.124 " #host and ip
And in my reverse proxy, I had it set to redirect from https://myurl to localhost:8001 .
How should I be setting it up instead?
Thank you very much again for your help.
from dockerfiles.
From what I've seen, the exposed port 9000 service is PHP-FPM or roughly equivalent. So you will need to stick something in front of it (like nginx, but others can work) to handle incoming HTTP(S) traffic, and then be configured to use the invoiceNinja container for PHP-FPM functionality for the tool. In my case I added a side-car/secondary container for nginx to do this.
Really aggravating that the documentation is so egregiously out of date with the actual behaviour of the container. It's not even a lot of work to change that documentation (which frankly isn't my job). So yeah, we (myself + others) have to resort to cobbling it together ourselves with half-assed and incomplete documentation.
Also having the same problem, I don't know how to do that :(
from dockerfiles.
For those who might care this is how I got it working on my setup where the only part of the image I wanted was the ninja invoice as I am running nginx and mysql on the host in front of multiple docker images and other sites.
nginx settings:
# Redirect to SSL server { listen _YOUR_SERVER_IP_:80; server_name _YOUR_DOMAIN_NAME_; return 301 https://_YOUR_DOMAIN_NAME_$request_uri; } # SSL Server server { listen _YOUR_SERVER_IP_:443 ssl http2; server_name _YOUR_DOMAIN_NAME_; # Assuming your using Lets-Encrypt for your server SSL ssl_certificate /etc/letsencrypt/live/_SERVER_NAME_/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/_SERVER_NAME_/privkey.pem; ssl_session_cache shared:SSL:10m; ssl_session_timeout 1h; ssl_buffer_size 1400; error_page 502 /errors/502.html; location ~ /\.git { return 404; } location ~* /storage/.*\.php$ { return 503; } # DO NOT CHANGE THIS "ROOT" PATH, IT MUST MATCH THE INTERNAL FIXED DOCKER INVOICE NINJA WEB PATH. 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$ { # 9000 is the default port, but if you run php-fpm on your server this port should be # changed to match the port you want to use via the docker-compose.yml port fastcgi_pass localhost:9000; fastcgi_split_path_info ^(.+\.php)(/.+)$; 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; } }
Docker-compose.yml
version: '3.7' services: app: image: invoiceninja/invoiceninja:latest env_file: env restart: unless-stopped volumes: - /var/www/app/public:/var/www/app/public:rw,delegated - /var/www/app/storage:/var/www/app/storage:rw,delegated - ./config/php/php.ini:/usr/local/etc/php/php.ini - ./config/php/php-cli.ini:/usr/local/etc/php/php-cli.ini ports: - 9000:9000
Please note a couple things:
- If is CRITICAL that your public directory be at
/var/www/app/public
Nginx needs to have the EXACT same path as PHP uses. At this point you can't change the dockers public directory. So this is a fixed value!!! This public directory will be automatically seeded/filled by the invoice ninja when it starts up so that nginx can serve static files like the css/js/images.- it is also critical that the ports match, so if you changed the docker file to
- 9005:9000
then in the Nginx configuration you need to use port 9005.- I also copied the two php config files from this repo and dropped them into ./config/php in this docker app folder.
- Port 9000 is a FastCGI/FPM port, it is NOT a browsable/http port, this is why you have to have Nginx in front of it and communicating with it using its own FastCGI/FPM protocol.
Now in my case, I actually created a symlink at
/var/www/app/public
to point to where I actually store my public files as I prefer to keep them with the app docker folder so the storage&public files actually live physically else where. Nginx must still be pointed and be able to see the files in that folder/var/www/app/public
(hence using a symlink here) or it can't pass on the php requests properly or serve any of the static files..
Are you running it in kubernetes/k8s?
If so, would you mind sharing a first-page-load waterfall? I'm asking because my k8s setup, while working, the initial load is still PAINNNNNNNN.
from dockerfiles.
No just a simple docker container. But I can tell you my first load is fairly fast lest than 2 seconds (was my total waterfall time after emptying the entire cache, so a totally fresh load) and I also have another task in the background downloading so normally it is way faster than 2 secs
from dockerfiles.
Related Issues (20)
- Grey screen after successful setup
- XMLHttpRequest error when requesting PDF files - after migrating between servers HOT 3
- QUEUE_CONNECTION configuration in Docker - can't find clear answer. HOT 1
- not opening login page
- Unable to view / print / download PDF invoices in docker HOT 11
- [BUG] Docker selfhosted bug HOT 8
- Connection reset by peer error with docker install HOT 2
- Raspberry Pi DB Error HOT 4
- Docker in k8s, testing, slow initial page load (including page refresh) HOT 15
- Tax line item not displaying in Totals area of invoice HOT 2
- after upgrade empty white page HOT 2
- Blank screen after upgrade HOT 5
- Permissions Error with Lost+Found Directory HOT 2
- git clone not pulling latest version HOT 6
- Update helm image? HOT 2
- Container startup only works with bind mount; `cp: can't create directory '/var/www/app/storage/app': Permission denied` HOT 5
- Http links requested when visiting a https page HOT 1
- Helm Chart commonLabels vs podLabels
- Database Availability Race Condition during Intialisation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dockerfiles.