mirror of
https://github.com/invoiceninja/dockerfiles.git
synced 2025-12-31 19:47:25 +01:00
merge improve-docker-compose
This commit is contained in:
65
README.md
65
README.md
@@ -5,6 +5,13 @@ If you feel your question is directly related to a code change or you want to se
|
|||||||
|
|
||||||
This image is based on `php:7.2-fpm` official version.
|
This image is based on `php:7.2-fpm` official version.
|
||||||
|
|
||||||
|
:crown: **Features**
|
||||||
|
|
||||||
|
:lock: Automatic HTTPS (:heart: [Caddy](https://caddyserver.com/))
|
||||||
|
:hammer: Fully production-ready through docker-compose
|
||||||
|
:pencil: Adjustable to your needs via environment variable
|
||||||
|
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
### Generate an application key
|
### Generate an application key
|
||||||
@@ -64,11 +71,59 @@ A list of environment variables can be found [here](https://github.com/invoiceni
|
|||||||
|
|
||||||
### With docker-compose
|
### With docker-compose
|
||||||
|
|
||||||
A ready to use docker-compose configuration can be found at [`./docker-compose`](https://github.com/invoiceninja/dockerfiles/tree/master/docker-compose).
|
Running Invoice Ninja with docker-compose gives you everything to quickly start. Before starting please make sure you configured your setup correctly. You can do so by opening the `docker-compose.yml` and may change the follwing items.
|
||||||
|
|
||||||
Run `cp .env.example .env` and change the environment variables as needed.
|
**Port**
|
||||||
The file assumes that all your persistent data is mounted from `/srv/invoiceninja/`.
|
|
||||||
Once started, the application should be accessible at http://localhost:8000.
|
_default: 80_
|
||||||
|
|
||||||
|
This is the port where your Invoice Ninja is reachable, when you type in `http://<your-domain.com>`. If it should be different than `80` make sure to call your installation `http://<your-domain.com>:<YOUR-PORT>`, e. g. `http://<your-domain.com>:8080`.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
ports:
|
||||||
|
- "8080:80" # To run it on port 8080
|
||||||
|
```
|
||||||
|
|
||||||
|
:warning: Make sure the port set is available and not occupied by another service on your host system.
|
||||||
|
|
||||||
|
**URL and application key**
|
||||||
|
|
||||||
|
_default: https://localhost_
|
||||||
|
|
||||||
|
For generating a proper application key see [generate an application key](#generate-an-application-key). Change the value where your Invoice Ninja installation should be reachable.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
environment:
|
||||||
|
- APP_URL=http://localhost
|
||||||
|
````
|
||||||
|
|
||||||
|
**MYSQL root password**
|
||||||
|
|
||||||
|
_default: ninjaAdm1nPassword_
|
||||||
|
|
||||||
|
The mysql database server comes with two users: one for accessing the Invoice Ninja database and the `root` user. Please change the default password for `root` to something more special :wink:
|
||||||
|
|
||||||
|
**Volumes and directories**
|
||||||
|
|
||||||
|
_default: volumes_
|
||||||
|
|
||||||
|
This is the place where your uploaded files are stored. Normally this is a so called _volume_ which can be reused by different docker containers. One might prefer to store the files directly on the host system - for this the config section is prepared with what is called _bind-mounted host directory_. Just adjust the paths and Invoice Ninja stores the user files on the host system.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
volumes:
|
||||||
|
...
|
||||||
|
# Configure your mounted directories, make sure the folder 'public' and 'storage'
|
||||||
|
# exist, before mounting them
|
||||||
|
#- public:/var/www/app/public
|
||||||
|
#- storage:/var/www/app/storage
|
||||||
|
# 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
|
||||||
|
```
|
||||||
|
|
||||||
|
The sample above stores the files on the post at `./docker/app/public` and `./docker/app/storage`.
|
||||||
|
|
||||||
|
:warning: If using bind-mounted host directories make sure they exists and have proper rights. See [here](#create-folders-for-data-persistence) for details.
|
||||||
|
|
||||||
|
|
||||||
## Debugging your Docker setup
|
## Debugging your Docker setup
|
||||||
@@ -77,7 +132,7 @@ Even when running your Invoice Ninja setup with Docker - errors can occur. Depen
|
|||||||
|
|
||||||
### Show logs without `docker-compose`
|
### Show logs without `docker-compose`
|
||||||
|
|
||||||
If you are not running the `docker-compose` you first need to find the container id for your php container with `docker ps`. Then you can run
|
If you are not running `docker-compose` you first need to find the container id for your php container with `docker ps`. Then you can run
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker logs -f <CONTAINER NAME>
|
docker logs -f <CONTAINER NAME>
|
||||||
|
|||||||
7
config/caddy/Caddyfile
Normal file
7
config/caddy/Caddyfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{$APP_URL} {
|
||||||
|
root * /var/www/app/public
|
||||||
|
php_fastcgi app:9000
|
||||||
|
encode zstd gzip
|
||||||
|
templates
|
||||||
|
file_server browse
|
||||||
|
}
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
user www-data;
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 768;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
upstream backend {
|
|
||||||
server app:9000;
|
|
||||||
}
|
|
||||||
include /etc/nginx/mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
gzip on;
|
|
||||||
gzip_disable "msie6";
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 80 default;
|
|
||||||
server_name your_ininja_site;
|
|
||||||
|
|
||||||
root /var/www/app/public;
|
|
||||||
|
|
||||||
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; }
|
|
||||||
|
|
||||||
sendfile off;
|
|
||||||
|
|
||||||
location ~ \.php$ {
|
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
||||||
fastcgi_pass backend;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ /\.ht {
|
|
||||||
deny all;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
version: '3.6'
|
version: '3.6'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
nginx:
|
server:
|
||||||
image: nginx:alpine
|
image: caddy:alpine
|
||||||
restart: always
|
restart: always
|
||||||
|
environment:
|
||||||
|
- APP_URL=https://localhost
|
||||||
volumes:
|
volumes:
|
||||||
# Vhost configuration
|
# Vhost configuration
|
||||||
- ./config/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
- ./config/caddy/Caddyfile:/etc/caddy/Caddyfile
|
||||||
|
|
||||||
# Configure your mounted directories, make sure the folder 'public' and 'storage'
|
# Configure your mounted directories, make sure the folder 'public' and 'storage'
|
||||||
# exist, before mounting them
|
# exist, before mounting them
|
||||||
@@ -21,6 +23,7 @@ services:
|
|||||||
# Feel free to modify depending what port is already occupied
|
# Feel free to modify depending what port is already occupied
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
networks:
|
networks:
|
||||||
- invoiceninja
|
- invoiceninja
|
||||||
|
|
||||||
@@ -28,7 +31,9 @@ services:
|
|||||||
image: invoiceninja/invoiceninja:alpine
|
image: invoiceninja/invoiceninja:alpine
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
|
- APP_URL=https://localhost
|
||||||
|
- APP_KEY=<INSERT THE GENERATED APPLICATION KEY HERE>
|
||||||
|
- DB_HOST=db
|
||||||
volumes:
|
volumes:
|
||||||
# Configure your mounted directories, make sure the folder 'public' and 'storage'
|
# Configure your mounted directories, make sure the folder 'public' and 'storage'
|
||||||
# exist, before mounting them
|
# exist, before mounting them
|
||||||
@@ -45,6 +50,11 @@ services:
|
|||||||
db:
|
db:
|
||||||
image: mysql:5
|
image: mysql:5
|
||||||
restart: always
|
restart: always
|
||||||
|
environment:
|
||||||
|
- MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword
|
||||||
|
- MYSQL_USER=ninja
|
||||||
|
- MYSQL_PASSWORD=ninja
|
||||||
|
- MYSQL_DATABASE=ninja
|
||||||
volumes:
|
volumes:
|
||||||
- mysql-data:/var/lib/mysql:rw
|
- mysql-data:/var/lib/mysql:rw
|
||||||
# you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
|
# you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
|
||||||
@@ -53,27 +63,24 @@ services:
|
|||||||
- invoiceninja
|
- invoiceninja
|
||||||
|
|
||||||
|
|
||||||
cron:
|
# cron:
|
||||||
image: invoiceninja/invoiceninja
|
# image: invoiceninja/invoiceninja
|
||||||
env_file: .env
|
# volumes:
|
||||||
volumes:
|
# - storage:/var/www/app/storage
|
||||||
- storage:/var/www/app/storage
|
# - logo:/var/www/app/public/logo
|
||||||
- logo:/var/www/app/public/logo
|
# - public:/var/www/app/public
|
||||||
- public:/var/www/app/public
|
# entrypoint: |
|
||||||
entrypoint: |
|
# bash -c 'bash -s <<EOF
|
||||||
bash -c 'bash -s <<EOF
|
# trap "break;exit" SIGHUP SIGINT SIGTERM
|
||||||
trap "break;exit" SIGHUP SIGINT SIGTERM
|
# sleep 300s
|
||||||
sleep 300s
|
# while /bin/true; do
|
||||||
while /bin/true; do
|
# ./artisan ninja:send-invoices
|
||||||
./artisan ninja:send-invoices
|
# ./artisan ninja:send-reminders
|
||||||
./artisan ninja:send-reminders
|
# sleep 1d
|
||||||
sleep 1d
|
# done
|
||||||
done
|
# EOF'
|
||||||
EOF'
|
# networks:
|
||||||
networks:
|
# - invoiceninja
|
||||||
- invoiceninja
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mysql-data:
|
mysql-data:
|
||||||
|
|||||||
Reference in New Issue
Block a user