Invoice & Accounting Stack
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:latest4 container_name: invoice-ninja5 restart: unless-stopped6 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-db12 - DB_DATABASE=invoiceninja13 - DB_USERNAME=${DB_USER}14 - DB_PASSWORD=${DB_PASSWORD}15 - REDIS_HOST=invoice-ninja-redis16 - 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/public23 - invoice_ninja_storage:/var/www/app/storage24 depends_on: 25 - invoice-ninja-db26 - invoice-ninja-redis2728 invoice-ninja-db: 29 image: mysql:8.030 container_name: invoice-ninja-db31 restart: unless-stopped32 environment: 33 - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}34 - MYSQL_DATABASE=invoiceninja35 - MYSQL_USER=${DB_USER}36 - MYSQL_PASSWORD=${DB_PASSWORD}37 volumes: 38 - invoice_ninja_db_data:/var/lib/mysql3940 invoice-ninja-redis: 41 image: redis:7-alpine42 container_name: invoice-ninja-redis43 restart: unless-stopped4445volumes: 46 invoice_ninja_public: 47 invoice_ninja_storage: 48 invoice_ninja_db_data: .env Template
.env
1# Invoice Ninja Stack2IN_PORT=808034# App key (generate with: openssl rand -base64 32)5APP_KEY=base64:your-app-key67# Database8DB_USER=invoiceninja9DB_PASSWORD=invoiceninja_password10DB_ROOT_PASSWORD=root_password1112# Email (optional)13MAIL_MAILER=smtp14MAIL_HOST=smtp.example.com15MAIL_PORT=58716MAIL_USERNAME=your-email@example.com17MAIL_PASSWORD=your-email-passwordUsage Notes
- 1Invoice Ninja at http://localhost:8080
- 2First visit runs setup wizard
- 3Create clients, products, invoices
- 4Accept payments via Stripe, PayPal, etc.
- 5Generate PDF invoices and quotes
- 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 file2cat > docker-compose.yml << 'EOF'3services:4 invoice-ninja:5 image: invoiceninja/invoiceninja:latest6 container_name: invoice-ninja7 restart: unless-stopped8 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-db14 - DB_DATABASE=invoiceninja15 - DB_USERNAME=${DB_USER}16 - DB_PASSWORD=${DB_PASSWORD}17 - REDIS_HOST=invoice-ninja-redis18 - 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/public25 - invoice_ninja_storage:/var/www/app/storage26 depends_on:27 - invoice-ninja-db28 - invoice-ninja-redis2930 invoice-ninja-db:31 image: mysql:8.032 container_name: invoice-ninja-db33 restart: unless-stopped34 environment:35 - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}36 - MYSQL_DATABASE=invoiceninja37 - MYSQL_USER=${DB_USER}38 - MYSQL_PASSWORD=${DB_PASSWORD}39 volumes:40 - invoice_ninja_db_data:/var/lib/mysql4142 invoice-ninja-redis:43 image: redis:7-alpine44 container_name: invoice-ninja-redis45 restart: unless-stopped4647volumes:48 invoice_ninja_public:49 invoice_ninja_storage:50 invoice_ninja_db_data:51EOF5253# 2. Create the .env file54cat > .env << 'EOF'55# Invoice Ninja Stack56IN_PORT=80805758# App key (generate with: openssl rand -base64 32)59APP_KEY=base64:your-app-key6061# Database62DB_USER=invoiceninja63DB_PASSWORD=invoiceninja_password64DB_ROOT_PASSWORD=root_password6566# Email (optional)67MAIL_MAILER=smtp68MAIL_HOST=smtp.example.com69MAIL_PORT=58770MAIL_USERNAME=your-email@example.com71MAIL_PASSWORD=your-email-password72EOF7374# 3. Start the services75docker compose up -d7677# 4. View logs78docker compose logs -fOne-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 | bashTroubleshooting
- 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
Components
invoice-ninjamysqlredis
Tags
#invoicing#accounting#business#finance#invoice-ninja
Category
E-Commerce & BusinessAd Space
Shortcuts: C CopyF FavoriteD Download