# Invoice Ninja Official Stack Template # Based on: https://github.com/invoiceninja/dockerfiles # Adapted for Traefik reverse proxy integration version: '3.7' services: server: image: nginx restart: always env_file: env volumes: - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro - ./docker/app/public:/var/www/app/public:ro depends_on: - app networks: - invoiceninja # Internal network for app communication - traefik # External network for Traefik routing labels: # Enable Traefik routing - "traefik.enable=true" # Router configuration - "traefik.http.routers.invoiceninja.rule=Host(`DOMAIN_HERE`)" - "traefik.http.routers.invoiceninja.entrypoints=websecure" - "traefik.http.routers.invoiceninja.tls.certresolver=letsencrypt" # Service configuration - "traefik.http.services.invoiceninja.loadbalancer.server.port=80" # Network specification (required when container is on multiple networks) - "traefik.docker.network=traefik" app: image: invoiceninja/invoiceninja:5 env_file: env restart: always volumes: - ./docker/app/public:/var/www/app/public:rw,delegated - ./docker/app/storage:/var/www/app/storage:rw,delegated depends_on: - db networks: - invoiceninja # Note: Container runs as user 1500, ensure volumes are owned by 1500:1500 db: image: mariadb:10.11 restart: always env_file: env volumes: - ./docker/mysql/data:/var/lib/mysql:rw,delegated networks: - invoiceninja healthcheck: test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] interval: 10s timeout: 5s retries: 5 networks: invoiceninja: # Internal network for service communication traefik: # External network - must already exist external: true # Required env file variables: # APP_URL=https://DOMAIN_HERE # APP_KEY=base64:... (generate with: docker run --rm invoiceninja/invoiceninja:5 php artisan key:generate --show) # DB_HOST=db # MYSQL_ROOT_PASSWORD=... # MYSQL_DATABASE=ninja # MYSQL_USER=ninja # MYSQL_PASSWORD=... # TRUSTED_PROXIES=* # MAIL_MAILER=log (or smtp/sendmail/etc) # Setup steps: # 1. Create service directory: mkdir -p ~/services/SERVICENAME/{config/nginx,docker/{app/{public,storage},mysql/data}} # 2. Download nginx config: curl -o config/nginx/in-vhost.conf https://raw.githubusercontent.com/invoiceninja/dockerfiles/master/config/nginx/in-vhost.conf # 3. Create env file with variables above # 4. Update DOMAIN_HERE in this file # 5. Set volume permissions: sudo chown -R 1500:1500 docker/app # 6. Deploy: docker compose up -d # 7. Run migrations: docker exec CONTAINER_app php artisan migrate --force # 8. Optimize: docker exec CONTAINER_app php artisan optimize