From af7744055543ce28d9312df44cda2bd693bda649 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 5 Jan 2021 10:46:55 +1100 Subject: [PATCH 1/5] changes for README --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++--- config/hosts | 1 + docker-compose.yml | 13 ++++++++--- entrypoint.sh | 1 + 4 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 config/hosts diff --git a/README.md b/README.md index 56121f6..a57528b 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,66 @@ # Docker for [Invoice Ninja](https://www.invoiceninja.com/) -:bulb: Please consider posting your question on [StackOverflow](https://stackoverflow.com/) as this widens the audience that can help you. Just use the tag `invoice-ninja` and we are there to help. This is mostly related to the usage of Invoice Ninja and the docker setup. -If you feel your question is directly related to a code change or you want to sent in a change + PR Github is the right place, of course. - :crown: **Features** :lock: Automatic HTTPS (:heart: [Caddy](https://caddyserver.com/)) +:fire: NGINX webserver support [NGINX](https://nginx.com) :hammer: Fully production-ready through docker-compose :pencil: Adjustable to your needs via environment variable +## Quickstart V5 Launch + +The dockerfile has been revamped to make is easier to get started, by default the base image selected in 5 which will pull in the latest v5 stable image. + +``` +git clone https://github.com/invoiceninja/dockerfiles.git +cd dockerfiles +``` + +Instead of defining our environment variables inside our docker-compose.yml file we now define this in the ```env``` file, open this file up and insert your APP_URL and your APP_KEY + +``` +APP_URL=http://in.localhost:8003/ +APP_KEY= +APP_DEBUG=true +MULTI_DB_ENABLED=false +DB_HOST1=db +DB_USERNAME1=ninja +DB_PASSWORD1=ninja +DB_DATABASE1=ninja +PHANTOMJS_PDF_GENERATION=false +``` + +The ```APP_KEY``` can be generated by running + +``` +docker run --rm -it invoiceninja/invoiceninja php artisan key:generate --show +``` + +Copy the entire string and insert in the env file at ```APP_KEY=base64....``` + +To ensure folder permissions are correct when the container comes up for the first time it is important that you set the correct folder permissions on the ```docker``` folder. + +From the terminal run + +```sudo chown -R 1500:1500 docker/app``` + +### Note for people running the container locally on their PC ### + +If you are running the container locally, then the container will need to resolve the host, to support this you will want to insert your LAN IP address and the host name in the hosts file located in ```config/hosts``` + +For example, lets say your APP_URL is ```http://ninja.test:8000``` and your LAN IP is 192.168.0.124 the hosts file will have an entry looking like this: + + +```192.168.0.124 in5.localhost``` + + +All that is left to do now is bring up the container + + +``` docker-compose up -d``` + + ## Documentation diff --git a/config/hosts b/config/hosts new file mode 100644 index 0000000..bfebf84 --- /dev/null +++ b/config/hosts @@ -0,0 +1 @@ +192.168.0.124 local.pc.ip \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 1fca194..20321a4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,8 +4,7 @@ services: server: image: nginx restart: always - environment: - - APP_URL=http://in.localhost:8003 + env_file: env volumes: # Vhost configuration #- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com @@ -24,6 +23,8 @@ services: #- "443:443" networks: - invoiceninja + extra_hosts: + - "in5.localhost:192.168.0.124 " #host and ip app: image: invoiceninja/invoiceninja:5 @@ -40,6 +41,8 @@ services: - db networks: - invoiceninja + extra_hosts: + - "in5.localhost:192.168.0.124 " #host and ip db: image: mysql:5 @@ -56,6 +59,8 @@ services: - ./docker/mysql/data:/var/lib/mysql:rw,delegated networks: - invoiceninja + extra_hosts: + - "in5.localhost:192.168.0.124 " #host and ip # THIS IS ONLY A VALID CONFIGURATION FOR IN 5. DO NOT USE FOR IN 4. cron: @@ -75,7 +80,9 @@ services: EOF' networks: - invoiceninja - + extra_hosts: + - "in5.localhost:192.168.0.124 " #host and ip + # THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5. # cron: # image: invoiceninja/invoiceninja:alpine-4 diff --git a/entrypoint.sh b/entrypoint.sh index 6f1f972..10936d7 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -104,5 +104,6 @@ file_env 'S3_SECRET' # Run Laravel stuff php artisan config:cache php artisan optimize +php artisan migrate --force exec docker-php-entrypoint "$@" From 14c597312e6125a3c399f0949801e2012965d9eb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 5 Jan 2021 10:47:59 +1100 Subject: [PATCH 2/5] Fixes for formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a57528b..e79a8ef 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ :crown: **Features** :lock: Automatic HTTPS (:heart: [Caddy](https://caddyserver.com/)) -:fire: NGINX webserver support [NGINX](https://nginx.com) +:fire: NGINX webserver support [NGINX](https://nginx.org)) :hammer: Fully production-ready through docker-compose :pencil: Adjustable to your needs via environment variable From 98e41ad73b204331879384858e52422b22272537 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 5 Jan 2021 11:02:57 +1100 Subject: [PATCH 3/5] Rework crons --- config/cron.sh | 16 ++++++++++++++++ docker-compose.yml | 16 ++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) create mode 100755 config/cron.sh diff --git a/config/cron.sh b/config/cron.sh new file mode 100755 index 0000000..c951c66 --- /dev/null +++ b/config/cron.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +echo "Early Entry" + +cleanup () +{ + kill -s SIGTERM $! + exit 0 +} + +trap cleanup SIGINT SIGTERM + +while : +do + sleep 60 ; cd /var/www/app/ && php artisan schedule:run; +done diff --git a/docker-compose.yml b/docker-compose.yml index 20321a4..c9b2aff 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,8 +9,6 @@ services: # Vhost configuration #- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro - # Configure your mounted directories, make sure the folder 'public' and 'storage' - # exist, before mounting them # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data! - ./docker/app/public:/var/www/app/public:rw,delegated - ./docker/app/storage:/var/www/app/storage:rw,delegated @@ -19,7 +17,7 @@ services: # Run webserver nginx on port 80 # Feel free to modify depending what port is already occupied ports: - - "8003:80" + - "80:80" #- "443:443" networks: - invoiceninja @@ -70,19 +68,13 @@ services: - ./config/hosts:/etc/hosts:ro - ./docker/app/public:/var/www/app/public:rw,delegated - ./docker/app/storage:/var/www/app/storage:rw,delegated - entrypoint: | - /bin/sh -c 'sh -s < Date: Tue, 5 Jan 2021 11:09:56 +1100 Subject: [PATCH 4/5] fixes for entrypoint --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index 10936d7..e74e9e3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -84,6 +84,7 @@ fi # Set permission for web server to create/update files chown -R invoiceninja:www-data /var/www/app/storage /var/www/app/public /var/www/app/bootstrap +chmod +x /usr/local/bin/cron.sh # Initialize values that might be stored in a file file_env 'APP_KEY' From 253c3339cfbed5119b2cd29df1ded906267a9871 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 5 Jan 2021 11:51:50 +1100 Subject: [PATCH 5/5] Fixes for ReadMe --- README.md | 11 ++++++----- config/hosts | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e79a8ef..9d996c4 100644 --- a/README.md +++ b/README.md @@ -52,20 +52,21 @@ From the terminal run If you are running the container locally, then the container will need to resolve the host, to support this you will want to insert your LAN IP address and the host name in the hosts file located in ```config/hosts``` -For example, lets say your APP_URL is ```http://ninja.test:8000``` and your LAN IP is 192.168.0.124 the hosts file will have an entry looking like this: +For example, lets say your APP_URL is ```http://in5.test:8000``` and your LAN IP is 192.168.0.124 the hosts file will have an entry looking like this: -```192.168.0.124 in5.localhost``` +```192.168.0.124 in5.test``` +**Please note that PDF generation using local host your domain name MUST end in .test for your PDFs to generate correctly, this is a DNS resolver issue with chromium. All that is left to do now is bring up the container ``` docker-compose up -d``` +## Support + +If you discover a bug, please create and issue, if you query is general in nature please visit us on our [Forum ](https://forum.invoiceninja.com/) -## Documentation - -Please see our [wiki](https://github.com/invoiceninja/dockerfiles/wiki) for further guidance. diff --git a/config/hosts b/config/hosts index bfebf84..a34210d 100644 --- a/config/hosts +++ b/config/hosts @@ -1 +1 @@ -192.168.0.124 local.pc.ip \ No newline at end of file +192.168.0.124 in5.test \ No newline at end of file