Software & Applications

InvoiceShelf Docker Compose: Start to Verified Backups

Self host InvoiceShelf with Docker Compose, then verify persistence, HTTPS, backups, restores, and upgrades against current official image and configuration guidance.

InvoiceShelf self-hosted billing stack deployed with Docker Compose
InvoiceShelf self-hosted billing stack deployed with Docker Compose

To self-host InvoiceShelf with Docker Compose, first verify the current official image, release tag, supported database, environment variables, ports, and Compose requirements. Then run the app with persistent storage. Keep the database private, put HTTPS in front of the app, and test backups and container recreation before using real invoices. InvoiceShelf documents Docker as a self-hosting route and provides an official image and preconfigured Compose files.

Check the supported InvoiceShelf deployment first

Use the current InvoiceShelf download page and project repository as the authority for the deployment you plan to run. InvoiceShelf lists stable and insider release channels. Use the stable channel for business data unless you deliberately want preview software. The official site also provides an image and preconfigured Docker Compose files.

The documented minimal path uses SQLite. It publishes the web service on host port 8080, sets APP_URL, selects DB_CONNECTION=sqlite, and persists /var/www/html/storage. A separate database can help with independent dumps or different growth and recovery plans. However, the supplied material does not confirm that every current release supports MariaDB or PostgreSQL with the same variables. Confirm the release before adapting the example.

Check these values in the official files before writing compose.yml:

  • The official image name and an exact stable tag. The official quick start shows invoiceshelf/invoiceshelf, but available tags can change.
  • The supported database engines and required database version.
  • The exact database variables: driver, host, port, database name, username, and password.
  • The application URL variable and any trusted-host or reverse-proxy settings.
  • The internal web port and any required queue, PDF, or mail services.
  • The Docker Engine and Compose requirements for the selected release.

If the official files support only SQLite for your release, use that documented layout and persist the exact storage path. Do not infer production database support from a development Compose file or third-party listing.

Prepare the host and create a copy-adapted Compose project

Before starting, prepare a Linux host with Docker Engine and the Docker Compose plugin. You also need permission to manage containers, enough disk space for invoices and backups, and a domain name if you plan to publish InvoiceShelf through HTTPS. Keep the project directory private because it contains database credentials.

Create the directories and a private environment file:

Linux shell
sudo mkdir -p /opt/invoiceshelf/{app-data,attachments,db-data,backups}
sudo chown -R "$USER":"$USER" /opt/invoiceshelf
cd /opt/invoiceshelf
touch .env
chmod 600 .env

The exact environment-variable names and values depend on the release. Copy them from the current official example. The following shows intended values, not a guaranteed schema:

/opt/invoiceshelf/.env
INVOICESHELF_IMAGE=invoiceshelf/invoiceshelf:REPLACE_WITH_CURRENT_STABLE_TAG
APP_URL=https://billing.example.com
DB_CONNECTION=REPLACE_WITH_SUPPORTED_DRIVER
DB_HOST=db
DB_PORT=REPLACE_WITH_SUPPORTED_PORT
DB_DATABASE=invoiceshelf
DB_USERNAME=invoiceshelf
DB_PASSWORD=REPLACE_WITH_LONG_RANDOM_SECRET
DB_ROOT_PASSWORD=REPLACE_WITH_DIFFERENT_LONG_RANDOM_SECRET

Replace every marked value before starting. If the current official release uses other variable names, copy those names instead of forcing this example to fit.

Create compose.yml from the official service definition for the release you selected. This skeleton shows the required boundaries. The app and database share a private network. Only the app has a host-facing port. Persistent host directories hold application and database data.

compose.yml
services:
  app:
    image: ${INVOICESHELF_IMAGE}
    restart: unless-stopped
    env_file:
      - .env
    depends_on:
      db:
        condition: service_healthy
    networks:
      - frontend
      - backend
    volumes:
      - ./app-data:/var/www/html/storage
      - ./attachments:/var/www/html/storage/app/public
    ports:
      - "127.0.0.1:8080:80"

  db:
    image: REPLACE_WITH_OFFICIAL_DATABASE_IMAGE_AND_PINNED_TAG
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${DB_DATABASE}
      MYSQL_USER: ${DB_USERNAME}
      MYSQL_PASSWORD: ${DB_PASSWORD}
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
    volumes:
      - ./db-data:/var/lib/mysql
    networks:
      - backend
    healthcheck:
      test: ["CMD", "healthcheck-command-from-the-official-database-image"]
      interval: 10s
      timeout: 5s
      retries: 12

networks:
  frontend:
  backend:
    internal: true

The database image, health-check command, database environment keys, and application mount paths are placeholders. The retrieved material does not verify a current production MariaDB or PostgreSQL schema. Copy these details from the official Compose file for the release you chose. Do not use overlapping mounts until the image documentation confirms them. A wrong mount can hide files already inside the container.

For the documented SQLite route, remove the database service. Persist the exact official storage path instead of using the database skeleton. Validate the rendered Compose configuration before pulling images:

Linux shell
docker compose config

Check that the output contains pinned image tags, non-empty secrets, persistent host paths, and no published database port such as 3306:3306. Do not commit .env or backup files to a public repository.

Start the services and verify persistence

Start the database first when using a separate database service. This reveals database readiness problems before application errors obscure them.

  1. Pull and start the database service.
Linux shell
cd /opt/invoiceshelf
docker compose pull db
docker compose up -d db
docker compose ps
docker compose logs --tail=100 db

The database should become ready without a restart loop. If it does not, fix the image, credentials, permissions, disk space, or health check before starting the app.

  1. Pull and start the application after the database is ready.
Linux shell
docker compose pull app
docker compose up -d app
docker compose ps
docker compose logs --tail=200 app

Look for normal startup or completed migrations. Log wording varies by release. Connection errors usually indicate database readiness or mismatched host, port, or credentials. An unknown-variable error usually indicates a Compose file from another release.

  1. Test the local application endpoint.
Linux shell
curl -I http://127.0.0.1:8080

You should receive an HTTP response from InvoiceShelf, even if it redirects to a setup page. If the local endpoint works but the public URL later fails, check the reverse proxy, DNS, firewall, or certificate. Do not restart the app blindly.

  1. Open the local address or temporary hostname and complete first-run setup. Create a separate administrator account with a unique password. Store its recovery details in a password manager. Set APP_URL to the final HTTPS address before creating customer-facing links.
  2. Create a clearly identifiable test customer or invoice and, if applicable, upload an attachment. Refresh the page and record the test record's identifier.

Do not run docker compose down -v during the persistence test. Removing volumes is destructive.

  1. Recreate the containers without deleting persistent data.
Linux shell
docker compose down
docker compose up -d
docker compose ps

Sign in again and confirm that the test record and attachment remain. docker compose down removes containers and the Compose network, but it does not remove bind-mounted host directories. The test passes when InvoiceShelf is reachable, login works, and the same data remains after recreation.

Put InvoiceShelf behind HTTPS and configure email

Use a reverse proxy such as Caddy, Nginx Proxy Manager, or Traefik in front of InvoiceShelf. Point the billing hostname to the proxy. Obtain a certificate through its supported certificate flow. Then forward requests to the app's local host binding or a shared proxy network. Keep the database on the internal Compose network and publish no database port.

Set APP_URL to the HTTPS address. Apply any trusted-proxy, trusted-host, or forwarded-header settings required by the current release. The exact names must come from that release's documentation. Test the public HTTPS URL and the direct local endpoint. If the local endpoint works but the public request fails, check DNS, firewall rules, certificate issuance, and the proxy upstream in that order.

Configure email only after the web application works. Use the release's exact SMTP settings for server, port, encryption, username, password, sender address, and sender name. Send a test message to an address you control. Compare the result with the application mail log and the SMTP provider's delivery log. If it fails, check DNS resolution and outbound firewall policy from the app's network. Then check SMTP authentication and TLS mode.

Back up the database and files, then rehearse a restore

Back up structured database records and every persistent application directory. Include attachments, generated documents, configuration, and other application state. A database-only backup can omit files. A file-only backup can omit records.

Schedule a consistent database dump and copy the application files in the same maintenance window. For a MariaDB-style deployment, use the database client's documented dump command. Write the dump outside the live database directory. The exact command depends on the official database image:

Linux shell
mkdir -p /opt/invoiceshelf/backups
sudo docker compose exec -T db sh -c 'database-dump-command-using-the-official-client' > /opt/invoiceshelf/backups/invoiceshelf.sql
sudo tar -C /opt/invoiceshelf -czf /opt/invoiceshelf/backups/invoiceshelf-files.tar.gz app-data attachments

Do not use a raw copy of a live database directory as your only backup. Restrict backup-file permissions, encrypt backups, and copy them to storage separate from the server. Keep at least one copy that a compromised host cannot overwrite.

Restore the dump and files on an isolated host or separate Compose project. Use a test APP_URL. Do not expose the restored stack publicly, and leave production untouched. Verify login, existing invoices, attachments, PDF generation, and email configuration. Record the restore commands and the date of the last successful rehearsal. A backup is operationally useful only after this test succeeds.

An external drive and server are arranged for backing up InvoiceShelf data.
An external drive and server are arranged for backing up InvoiceShelf data.

Upgrade in stages and troubleshoot the failing layer

Before upgrading, record the current image tags. Save a verified database dump and file backup. Read the selected release's migration notes. Confirm the target image and database combination against the current official files. Keep the old image tag available until validation is complete.

  1. Save the current Compose files and .env in a private location.
  2. Pull the target images without deleting data.
  3. Pause public traffic if the release notes require a maintenance window.
  4. Start the database at its approved version. Then start InvoiceShelf and watch the migration logs.
  5. Check login, existing invoices, attachments, PDFs, SMTP, and the public HTTPS URL.
  6. Keep the release only after those checks pass.
Linux shell
docker compose config
docker compose pull
docker compose up -d db
docker compose logs --tail=200 db
docker compose up -d app
docker compose logs --tail=300 app
docker compose ps

If migrations fail or data is missing, stop the cutover instead of repeatedly restarting. Roll back only when the release notes support it. Restore the previous image and configuration. If the migration changed the schema, restore the database and files from the pre-upgrade backup. A database downgrade is not automatically safe.

Troubleshoot from the first failing layer:

  • The app exits: Inspect docker compose logs app, the image tag, required variables, file ownership, mounted paths, and available disk space. A missing or renamed variable often indicates a release mismatch.
  • The database connection fails: Inspect docker compose logs db. Compare the app's database host, port, name, username, and password with the database service. Confirm readiness and use the Compose service name rather than localhost.
  • Login loops or redirects: Check APP_URL, HTTPS forwarding headers, cookies, trusted-host settings, and the browser hostname. Do not erase application data as a first response.
  • Email fails: Test the SMTP hostname and port from the app's network. Then check encryption, credentials, sender policy, provider logs, and application mail logs.
  • Invoices or attachments disappear: Inspect the host directories and mounts with docker inspect. Check container-user permissions and look for a second mount hiding the expected directory. Restore a test backup before changing paths.
  • The proxy returns a gateway error: Request the local app endpoint and inspect application logs. Then inspect proxy upstream and certificate logs. A valid certificate does not prove that the upstream container is healthy.

Docker Compose is a poor fit if you cannot patch the host, protect secrets, monitor disk usage, or rehearse restores. The operator remains responsible for the server, firewall, Docker updates, DNS, TLS, SMTP credentials, access control, backups, and applicable business record-retention obligations.

Conclusion

The deployment is ready when the official image and configuration are verified. The app must survive container recreation with its data intact. The database must have no public port. HTTPS and SMTP must work, and a separate restore rehearsal must succeed. Keep the Compose files, image tags, backups, and restore notes together so the next upgrade is controlled rather than guesswork.

Frequently Asked Questions

Can I run InvoiceShelf with SQLite?

Yes. The official Docker quick start documents a minimal SQLite setup with persistent InvoiceShelf storage. Confirm that the selected current release still uses that layout. Back up the SQLite data consistently with attachments and other application files.

Should I expose the InvoiceShelf database port?

No. Keep the database on an internal Compose network. Publish only the application through a reverse proxy or local host binding. For administrative access, use a controlled tunnel or temporary firewall rule instead of leaving the database exposed.

What must an InvoiceShelf backup contain?

Back up the database dump and every persistent application directory containing invoices, attachments, generated documents, or configuration. Restore both on an isolated stack. Test login, invoices, attachments, document generation, and email configuration.

Sources

Everyday Self-Hosting Desk

Think Tech Editorial

Clear, non-intimidating guides for households and teams adopting self-hosted software.