From 80561ccbc042231d12a9cc1de23716d07e2c8552 Mon Sep 17 00:00:00 2001 From: Derek Cooper Date: Tue, 23 Jun 2026 00:31:50 -0700 Subject: [PATCH] created invoice ninja --- Invoice-Ninja/.env.example | 42 +++++++++ Invoice-Ninja/docker-compose-nfs.yaml | 126 ++++++++++++++++++++++++++ Invoice-Ninja/nginx/nginx.conf | 33 +++++++ 3 files changed, 201 insertions(+) create mode 100644 Invoice-Ninja/.env.example create mode 100644 Invoice-Ninja/docker-compose-nfs.yaml create mode 100644 Invoice-Ninja/nginx/nginx.conf diff --git a/Invoice-Ninja/.env.example b/Invoice-Ninja/.env.example new file mode 100644 index 0000000..7699d37 --- /dev/null +++ b/Invoice-Ninja/.env.example @@ -0,0 +1,42 @@ +# === Invoice Ninja === + +# Compose infrastructure (image versions, port, NFS) +IN_VERSION=5 +IN_NGINX_VERSION=alpine +IN_DB_VERSION=8 +IN_PORT=8080 +IN_NFS_SERVER=your-nfs-server-ip +IN_NFS_PUBLIC_DEVICE=:/path/to/invoice-ninja/public +IN_NFS_STORAGE_DEVICE=:/path/to/invoice-ninja/storage +IN_NFS_DB_DEVICE=:/path/to/invoice-ninja/db + +# Application +# Generate with: docker compose run --rm app php artisan key:generate --show +APP_KEY=base64:REPLACE_WITH_GENERATED_KEY +APP_URL=https://invoices.yourdomain.com +NINJA_ENVIRONMENT=selfhosted + +# Database +DB_HOST=db +DB_PORT=3306 +DB_ROOT_PASSWORD=changeme +DB_DATABASE=invoiceninja +DB_USERNAME=invoiceninja +DB_PASSWORD=changeme + +# Queue / Cache (defaults work for most self-hosted setups) +QUEUE_CONNECTION=database +CACHE_DRIVER=file +SESSION_DRIVER=file +PDF_GENERATOR=snappdf +LOG_CHANNEL=stderr + +# Mail (SMTP) +MAIL_MAILER=smtp +MAIL_HOST=smtp.yourdomain.com +MAIL_PORT=587 +MAIL_USERNAME=your@email.com +MAIL_PASSWORD=changeme +MAIL_ENCRYPTION=tls +MAIL_FROM_ADDRESS=invoices@yourdomain.com +MAIL_FROM_NAME=Invoice Ninja diff --git a/Invoice-Ninja/docker-compose-nfs.yaml b/Invoice-Ninja/docker-compose-nfs.yaml new file mode 100644 index 0000000..7e52f04 --- /dev/null +++ b/Invoice-Ninja/docker-compose-nfs.yaml @@ -0,0 +1,126 @@ +services: + db: + image: mysql:${IN_DB_VERSION:-8} + container_name: invoice-ninja-db + environment: + MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} + MYSQL_DATABASE: ${DB_DATABASE:-invoiceninja} + MYSQL_USER: ${DB_USERNAME:-invoiceninja} + MYSQL_PASSWORD: ${DB_PASSWORD} + volumes: + - in-db:/var/lib/mysql + healthcheck: + test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_ROOT_PASSWORD}"] + interval: 10s + timeout: 5s + retries: 5 + start_period: 30s + deploy: + resources: + limits: + memory: 512m + restart: unless-stopped + + app: + image: invoiceninja/invoiceninja:${IN_VERSION:-5} + container_name: invoice-ninja-app + env_file: .env + volumes: + - in-public:/var/www/app/public + - in-storage:/var/www/app/storage + depends_on: + db: + condition: service_healthy + healthcheck: + test: ["CMD", "php", "artisan", "--version"] + interval: 30s + timeout: 15s + retries: 5 + start_period: 90s + deploy: + resources: + limits: + memory: 512m + restart: unless-stopped + + scheduler: + image: invoiceninja/invoiceninja:${IN_VERSION:-5} + container_name: invoice-ninja-scheduler + env_file: .env + entrypoint: "" + command: ["sh", "-c", "while true; do php /var/www/app/artisan schedule:run --no-interaction; sleep 60; done"] + volumes: + - in-public:/var/www/app/public + - in-storage:/var/www/app/storage + depends_on: + app: + condition: service_healthy + deploy: + resources: + limits: + memory: 256m + restart: unless-stopped + + queue: + image: invoiceninja/invoiceninja:${IN_VERSION:-5} + container_name: invoice-ninja-queue + env_file: .env + entrypoint: "" + command: ["php", "/var/www/app/artisan", "queue:work", "--sleep=3", "--tries=3"] + volumes: + - in-public:/var/www/app/public + - in-storage:/var/www/app/storage + depends_on: + app: + condition: service_healthy + deploy: + resources: + limits: + memory: 256m + restart: unless-stopped + + nginx: + image: nginx:${IN_NGINX_VERSION:-alpine} + container_name: invoice-ninja-nginx + volumes: + - in-public:/var/www/app/public + - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro + ports: + - ${IN_PORT:-8080}:80 + depends_on: + app: + condition: service_healthy + healthcheck: + test: ["CMD-SHELL", "[ -f /var/run/nginx.pid ] && kill -0 $(cat /var/run/nginx.pid) || exit 1"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 30s + deploy: + resources: + limits: + memory: 128m + restart: unless-stopped + +volumes: + in-public: + name: invoice-ninja-public + driver: local + driver_opts: + type: nfs + o: "addr=${IN_NFS_SERVER},rw,noatime,rsize=65536,wsize=65536,timeo=600,nfsvers=4" + device: "${IN_NFS_PUBLIC_DEVICE}" + in-storage: + name: invoice-ninja-storage + driver: local + driver_opts: + type: nfs + o: "addr=${IN_NFS_SERVER},rw,noatime,rsize=65536,wsize=65536,timeo=600,nfsvers=4" + device: "${IN_NFS_STORAGE_DEVICE}" + in-db: + name: invoice-ninja-db + driver: local + driver_opts: + type: nfs + o: "addr=${IN_NFS_SERVER},rw,noatime,rsize=65536,wsize=65536,timeo=600,nfsvers=4" + device: "${IN_NFS_DB_DEVICE}" diff --git a/Invoice-Ninja/nginx/nginx.conf b/Invoice-Ninja/nginx/nginx.conf new file mode 100644 index 0000000..91f6e9f --- /dev/null +++ b/Invoice-Ninja/nginx/nginx.conf @@ -0,0 +1,33 @@ +server { + listen 80; + server_name _; + + root /var/www/app/public; + index index.php; + + client_max_body_size 100M; + + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-Content-Type-Options "nosniff"; + + 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; + } +}