Run InvoiceNinja - Invoice and Payment Manager - in Docker

What is InvoiceNinja?

[InvoiceNinja is a] powerful suite of features to invoice clients, facilitate payment, track-time & tasks, expenses, and more. -https://www.invoiceninja.com/invoicing-features/

Installing Docker

  1. Log into the Linux based device
  2. Run the following commands in the terminal
    # install prerequisites
    sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
    # add docker gpg key
    curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
    # add docker software repository
    sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
    # install docker
    sudo apt install docker-ce docker-compose containerd.io -y
    # enable and start docker service
    sudo systemctl enable docker && sudo systemctl start docker
    # add the current user to the docker group
    sudo usermod -aG docker $USER
    # reauthenticate for the new group membership to take effect
    su - $USER

Running the InvoiceNinja Container

  1. Now that Docker is installed, run the following commands to setup the InvoiceNinja Docker container and run it
    # create working directories
    mkdir ~/docker/invoiceninja/{public,storage} -p && mkdir ~/docker/mariadb -p && mkdir ~/docker/nginx -p
    # download the invoiceninja nginx config
    wget -O ~/docker/nginx/invoiceninja.conf https://raw.githubusercontent.com/invoiceninja/dockerfiles/master/config/nginx/in-vhost.conf
    # update the config file with the invoiceninja container name
    sed -i 's/fastcgi_pass app:9000;/fastcgi_pass invoiceninja:9000;/g' ~/docker/nginx/invoiceninja.conf && sed -i 's/listen 80 default_server;/listen 80;/g' ~/docker/nginx/invoiceninja.conf
    # set ownership on the working directories
    sudo chown "$USER":"$USER" ~/docker -R
    # allow the container to write to files/ and settings.php
    sudo chmod a+rwx -R ~/docker/invoiceninja
    # run the mariadb docker container
    docker run -d --name mariadb -e MYSQL_ROOT_PASSWORD=r00tp@$$ -e MYSQL_USER=invoiceninja_rw -e MYSQL_PASSWORD='!nv0ic3Ninj@!' -e MYSQL_DATABASE=invoiceninja -v ~/docker/mariadb:/var/lib/mysql -p 3306:3006 --restart=unless-stopped mariadb:latest
    # generate application key
    docker run --rm -it invoiceninja/invoiceninja php artisan key:generate --show
    # run the invoiceninja container
    # change the IN_USER_EMAIL and IN_PASSWORD variables to setup the default user
    # update the APP_KEY variable with the key generated earlier
    docker run -d --name=invoiceninja --link mariadb -p 8080:80 -v ~/docker/invoiceninja/public:/var/www/app/public -v ~/docker/invoiceninja/storage:/var/www/app/storage -e IN_USER_EMAIL='i12bretro@i12bretro.local' -e IN_PASSWORD='SomethingSecure!' -e REQUIRE_HTTPS=false -e APP_ENV='production' -e APP_DEBUG=0 -e APP_URL='http://ubuntuserver.local:8080' -e APP_KEY='<%key generated earlier%>' -e APP_CIPHER='AES-256-CBC' -e DB_TYPE='mysql' -e DB_STRICT='false' -e DB_HOST='mariadb' -e DB_DATABASE='invoiceninja' -e DB_USERNAME='invoiceninja_rw' -e DB_PASSWORD='!nv0ic3Ninj@!' --restart=unless-stopped invoiceninja/invoiceninja
    # run the nginx container
    docker run -d --name nginx --link invoiceninja -p 8081:80 -v ~/docker/invoiceninja/public:/var/www/app/public:ro -v ~/docker/nginx:/etc/nginx/conf.d:ro --restart=unless-stopped nginx
  2. Open a web browser and navigate to http://DNSorIP:8081
  3. Login with the Email and Password setup in the InvoiceNinja container variables > Click Login with email
  4. On the Welcome dialog, enter a company name and select the Light or Dark theme > Click Save
  5. Welcome to InvoiceNinja

Documentation: https://hub.docker.com/r/invoiceninja/invoiceninja