docker.recipes

Invoice & Accounting Stack

intermediate

Invoice Ninja for invoicing with MySQL database and self-hosted email

Overview

Invoice Ninja is a comprehensive open-source invoicing and billing platform designed for freelancers, small businesses, and enterprises who need professional invoice management without the overhead of expensive proprietary solutions. Built with PHP and Laravel, Invoice Ninja offers a complete suite of features including client management, invoice generation, payment processing, expense tracking, and project time tracking, making it a powerful alternative to services like FreshBooks or QuickBooks Online. This deployment creates a production-ready Invoice Ninja environment using three specialized containers: the main Invoice Ninja application server, a MySQL 8.0 database for persistent data storage, and Redis for session management and caching. The stack leverages MySQL's robust ACID compliance and InnoDB storage engine to ensure data integrity for financial records, while Redis provides sub-millisecond response times for user sessions and application caching. This configuration is ideal for businesses requiring a self-hosted invoicing solution with complete data control, customizable branding, and the ability to integrate with multiple payment gateways including Stripe, PayPal, and bank transfers while maintaining compliance with financial data regulations.

Key Features

  • Professional invoice and quote generation with customizable templates and branding
  • Multi-gateway payment processing supporting Stripe, PayPal, Square, and 45+ other payment providers
  • Client portal with self-service invoice viewing, payment submission, and document download
  • Comprehensive expense tracking with receipt uploads and categorization
  • Project time tracking with billable hours and automatic invoice generation
  • Multi-currency support with real-time exchange rates and localization for 75+ languages
  • Recurring invoice automation with flexible scheduling and dunning management
  • Advanced reporting dashboard with profit/loss statements, aging reports, and tax summaries

Common Use Cases

  • 1Freelancers and consultants managing client billing, project time tracking, and payment collection
  • 2Small to medium businesses requiring professional invoicing with custom branding and multiple payment options
  • 3Service-based companies needing integrated time tracking, expense management, and automated recurring billing
  • 4Agencies managing multiple clients with project-based billing and detailed financial reporting
  • 5International businesses requiring multi-currency invoicing and localized tax compliance
  • 6Companies transitioning from expensive SaaS solutions like QuickBooks or FreshBooks to reduce costs
  • 7Organizations requiring complete data sovereignty and GDPR compliance for financial records

Prerequisites

  • Docker Engine 20.10+ and Docker Compose V2 for container orchestration
  • Minimum 2GB RAM (4GB+ recommended) to support MySQL database operations and Invoice Ninja application
  • Available port 8080 for web interface access (configurable via IN_PORT environment variable)
  • SMTP email server credentials for invoice delivery and client notifications
  • SSL certificate and reverse proxy setup for production deployment with secure payment processing
  • Basic understanding of Invoice Ninja configuration for payment gateway setup and tax rules

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 invoice-ninja:
3 image: invoiceninja/invoiceninja:latest
4 container_name: invoice-ninja
5 restart: unless-stopped
6 ports:
7 - "${IN_PORT:-8080}:80"
8 environment:
9 - APP_URL=http://localhost:${IN_PORT:-8080}
10 - APP_KEY=${APP_KEY}
11 - DB_HOST=invoice-ninja-db
12 - DB_DATABASE=invoiceninja
13 - DB_USERNAME=${DB_USER}
14 - DB_PASSWORD=${DB_PASSWORD}
15 - REDIS_HOST=invoice-ninja-redis
16 - MAIL_MAILER=${MAIL_MAILER:-log}
17 - MAIL_HOST=${MAIL_HOST}
18 - MAIL_PORT=${MAIL_PORT:-587}
19 - MAIL_USERNAME=${MAIL_USERNAME}
20 - MAIL_PASSWORD=${MAIL_PASSWORD}
21 volumes:
22 - invoice_ninja_public:/var/www/app/public
23 - invoice_ninja_storage:/var/www/app/storage
24 depends_on:
25 - invoice-ninja-db
26 - invoice-ninja-redis
27
28 invoice-ninja-db:
29 image: mysql:8.0
30 container_name: invoice-ninja-db
31 restart: unless-stopped
32 environment:
33 - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
34 - MYSQL_DATABASE=invoiceninja
35 - MYSQL_USER=${DB_USER}
36 - MYSQL_PASSWORD=${DB_PASSWORD}
37 volumes:
38 - invoice_ninja_db_data:/var/lib/mysql
39
40 invoice-ninja-redis:
41 image: redis:7-alpine
42 container_name: invoice-ninja-redis
43 restart: unless-stopped
44
45volumes:
46 invoice_ninja_public:
47 invoice_ninja_storage:
48 invoice_ninja_db_data:

.env Template

.env
1# Invoice Ninja Stack
2IN_PORT=8080
3
4# App key (generate with: openssl rand -base64 32)
5APP_KEY=base64:your-app-key
6
7# Database
8DB_USER=invoiceninja
9DB_PASSWORD=invoiceninja_password
10DB_ROOT_PASSWORD=root_password
11
12# Email (optional)
13MAIL_MAILER=smtp
14MAIL_HOST=smtp.example.com
15MAIL_PORT=587
16MAIL_USERNAME=your-email@example.com
17MAIL_PASSWORD=your-email-password

Usage Notes

  1. 1Invoice Ninja at http://localhost:8080
  2. 2First visit runs setup wizard
  3. 3Create clients, products, invoices
  4. 4Accept payments via Stripe, PayPal, etc.
  5. 5Generate PDF invoices and quotes
  6. 6Configure email for sending invoices

Individual Services(3 services)

Copy individual services to mix and match with your existing compose files.

invoice-ninja
invoice-ninja:
  image: invoiceninja/invoiceninja:latest
  container_name: invoice-ninja
  restart: unless-stopped
  ports:
    - ${IN_PORT:-8080}:80
  environment:
    - APP_URL=http://localhost:${IN_PORT:-8080}
    - APP_KEY=${APP_KEY}
    - DB_HOST=invoice-ninja-db
    - DB_DATABASE=invoiceninja
    - DB_USERNAME=${DB_USER}
    - DB_PASSWORD=${DB_PASSWORD}
    - REDIS_HOST=invoice-ninja-redis
    - MAIL_MAILER=${MAIL_MAILER:-log}
    - MAIL_HOST=${MAIL_HOST}
    - MAIL_PORT=${MAIL_PORT:-587}
    - MAIL_USERNAME=${MAIL_USERNAME}
    - MAIL_PASSWORD=${MAIL_PASSWORD}
  volumes:
    - invoice_ninja_public:/var/www/app/public
    - invoice_ninja_storage:/var/www/app/storage
  depends_on:
    - invoice-ninja-db
    - invoice-ninja-redis
invoice-ninja-db
invoice-ninja-db:
  image: mysql:8.0
  container_name: invoice-ninja-db
  restart: unless-stopped
  environment:
    - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
    - MYSQL_DATABASE=invoiceninja
    - MYSQL_USER=${DB_USER}
    - MYSQL_PASSWORD=${DB_PASSWORD}
  volumes:
    - invoice_ninja_db_data:/var/lib/mysql
invoice-ninja-redis
invoice-ninja-redis:
  image: redis:7-alpine
  container_name: invoice-ninja-redis
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 invoice-ninja:
5 image: invoiceninja/invoiceninja:latest
6 container_name: invoice-ninja
7 restart: unless-stopped
8 ports:
9 - "${IN_PORT:-8080}:80"
10 environment:
11 - APP_URL=http://localhost:${IN_PORT:-8080}
12 - APP_KEY=${APP_KEY}
13 - DB_HOST=invoice-ninja-db
14 - DB_DATABASE=invoiceninja
15 - DB_USERNAME=${DB_USER}
16 - DB_PASSWORD=${DB_PASSWORD}
17 - REDIS_HOST=invoice-ninja-redis
18 - MAIL_MAILER=${MAIL_MAILER:-log}
19 - MAIL_HOST=${MAIL_HOST}
20 - MAIL_PORT=${MAIL_PORT:-587}
21 - MAIL_USERNAME=${MAIL_USERNAME}
22 - MAIL_PASSWORD=${MAIL_PASSWORD}
23 volumes:
24 - invoice_ninja_public:/var/www/app/public
25 - invoice_ninja_storage:/var/www/app/storage
26 depends_on:
27 - invoice-ninja-db
28 - invoice-ninja-redis
29
30 invoice-ninja-db:
31 image: mysql:8.0
32 container_name: invoice-ninja-db
33 restart: unless-stopped
34 environment:
35 - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
36 - MYSQL_DATABASE=invoiceninja
37 - MYSQL_USER=${DB_USER}
38 - MYSQL_PASSWORD=${DB_PASSWORD}
39 volumes:
40 - invoice_ninja_db_data:/var/lib/mysql
41
42 invoice-ninja-redis:
43 image: redis:7-alpine
44 container_name: invoice-ninja-redis
45 restart: unless-stopped
46
47volumes:
48 invoice_ninja_public:
49 invoice_ninja_storage:
50 invoice_ninja_db_data:
51EOF
52
53# 2. Create the .env file
54cat > .env << 'EOF'
55# Invoice Ninja Stack
56IN_PORT=8080
57
58# App key (generate with: openssl rand -base64 32)
59APP_KEY=base64:your-app-key
60
61# Database
62DB_USER=invoiceninja
63DB_PASSWORD=invoiceninja_password
64DB_ROOT_PASSWORD=root_password
65
66# Email (optional)
67MAIL_MAILER=smtp
68MAIL_HOST=smtp.example.com
69MAIL_PORT=587
70MAIL_USERNAME=your-email@example.com
71MAIL_PASSWORD=your-email-password
72EOF
73
74# 3. Start the services
75docker compose up -d
76
77# 4. View logs
78docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/invoice-accounting-stack/run | bash

Troubleshooting

  • Database connection failed errors: Verify DB_USER, DB_PASSWORD, and DB_ROOT_PASSWORD environment variables match between invoice-ninja and invoice-ninja-db containers
  • Invoice Ninja setup wizard not loading: Check that APP_KEY environment variable is set to a valid 32-character base64 string (generate with 'php artisan key:generate')
  • PDF generation failing for invoices: Increase invoice-ninja container memory allocation and verify storage volume permissions for /var/www/app/storage
  • Email sending not working: Configure MAIL_MAILER, MAIL_HOST, MAIL_PORT, MAIL_USERNAME, and MAIL_PASSWORD environment variables with valid SMTP credentials
  • Redis connection errors in Invoice Ninja logs: Ensure invoice-ninja-redis container is running and accessible via the Redis hostname configuration
  • Application performance issues: Monitor invoice_ninja_db_data volume disk usage and consider enabling MySQL query cache or increasing Redis memory allocation

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space