invoiceninja / dockerfiles

Docker files for Invoice Ninja
https://hub.docker.com/r/invoiceninja/invoiceninja
GNU General Public License v2.0
418 stars 268 forks source link

<user experience> High complexity for a single person small business. #566

Open tamis-laan opened 8 months ago

tamis-laan commented 8 months ago

I'm looking into invoice ninja and I was really impressed watching some video tutorials on youtube.

However when trying to self host IN I feel like it's to complex and I'm just afraid of the maintenance issues that will arise in the future. I understand the design choices as it allows for redundancy, scaling and flexibility. But as a single person business it's problematic.

What would really work for me is a single container that incorporates everything, something like invoiceninja/invoiceninja-compact. It would contain the database, invoiceninja itself and the fastcgi reverse proxy with maybe the option to use an external mysql database.

This would allow me to incorporate IN in my existing docker compose stack without trying to hack a separate git repo into it.

mwa85 commented 7 months ago

Hi there a little input here and hope that can help you.

If your are looking for a docker run way there is already your "compact w/external database": This is documented on official Invoiceninja DockerHub: https://hub.docker.com/r/invoiceninja/invoiceninja

Create your key

docker run --rm -it invoiceninja/invoiceninja php artisan key:generate --show

Run with your env-variables customized

docker run -d \
  -v /var/invoiceninja/public:/var/app/public \
  -v /var/invoiceninja/storage:/var/app/storage \
  -e APP_ENV='production' \
  -e APP_DEBUG=0 \
  -e APP_URL='http://ninja.dev' \
  -e APP_KEY='<INSERT THE GENERATED APPLICATION KEY HERE>' \
  -e APP_CIPHER='AES-256-CBC' \
  -e DB_TYPE='mysql' \
  -e DB_STRICT='false' \
  -e DB_HOST='localhost' \
  -e DB_DATABASE='ninja' \
  -e DB_USERNAME='ninja' \
  -e DB_PASSWORD='ninja' \
  -p '80:80' \
  invoiceninja/invoiceninja

You can change the need of volume bind and use docker volume by just customizing the following:

  -v /var/invoiceninja/public:/var/app/public \
  -v /var/invoiceninja/storage:/var/app/storage \

into the following:

  -v public:/var/app/public \
  -v storage:/var/app/storage \

Then having reached a truly one-liner docker run without full CLI / bash access to the server.

If a database is needed within the service then the right way is as it is done today with a compose, there is no reason for IN devs to use time for maintaining a MySQL with the images. Here I have been running InvoiceNinja with docker volumes from a Portainer/Dockage and plain vanilla docker-compose CLI with the need of git clone/pull into my server with existing:

The simple compose requirement:

volumes/binds for config and a persistent storages (volume / bind)

and for files that are required (pre-created config)

Here the docker-compose.yml can bee changes to include internal MySQL service or without and then point to external MySQL server, here is an example on how I'm running with docker-compose CLI without the pull (yes I needed to touch and copy config of the "in-vhost.conf" and then the "hosts" files that I have in volume bind on the host).

version: '3.7'

services:

  server:
    image: nginx
    restart: always
    env_file: stack.env
    volumes:
      - ./in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro
      - public:/var/www/app/public:ro
    depends_on:
      - app
    ports:
      - "80:80"
      - "443:443"
    networks:
      - invoiceninja
      - ingress
    extra_hosts:
      - "in5.localhost:192.168.0.124 " #host and ip

  app:
    image: invoiceninja/invoiceninja:5
    env_file: stack.env
    restart: always
    volumes:
      - ./hosts:/etc/hosts:ro
      - public:/var/www/app/public:rw,delegated
      - storage:/var/www/app/storage:rw,delegated
    networks:
      - invoiceninja
    extra_hosts:
      - "in5.localhost:192.168.0.124 " #host and ip

networks:
  invoiceninja:
  ingress:
    external: true

volumes:
  storage:
  public:
TomTinking commented 7 months ago

volumes: storage: public:

Is the nugget which needs adding to the docs. Seems (for reasons I don't quite get) when running compose.. declare the volumes and networks to the stack they get instantiated by compose.. and referenced them in the app container.. this got my stack up and running.. none of the permissions hacks worked for me. So thanks @mwa85

hillelcoren commented 7 months ago

@TomTinking thanks for your comment!

@turbo124 @lwj5 any suggestions to make this clearer/easier for people?

daviewales commented 6 months ago

I'll add a usecase.

I'm trying to evaluate Invoice Ninja by installing it to my Raspberry Pi. My plan was:

However, (perhaps due to my lack of docker-compose knowledge), I can't seem to be able to do this.

I suspect that I am trying to do something the wrong way. For example, I want to be able to just go to http://10.1.1.123:8003 or http://raspberrypi.local:8003 in my laptop browser (the IP of the Pi on the LAN, and the configured port), and have it work. But this doesn't seem to be a supported mode of operation with the docker-compose file from this repository.

My docker-compose.yml:

``` version: '3.7' services: server: image: docker.io/nginx restart: always env_file: env volumes: # Vhost configuration #- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro - ./docker/app/public:/var/www/app/public:ro depends_on: - app # Run webserver nginx on port 80 # Feel free to modify depending what port is already occupied ports: - "8003:80" #- "443:443" networks: - invoiceninja # extra_hosts: # - "in5.localhost:192.168.0.124 " #host and ip app: image: docker.io/invoiceninja/invoiceninja:5 env_file: env restart: always volumes: - ./config/hosts:/etc/hosts:ro - ./docker/app/public:/var/www/app/public:rw,delegated - ./docker/app/storage:/var/www/app/storage:rw,delegated - ./config/php/php.ini:/usr/local/etc/php/php.ini - ./config/php/php-cli.ini:/usr/local/etc/php/php-cli.ini depends_on: - db networks: - invoiceninja #extra_hosts: # - "in5.localhost:192.168.0.124 " #host and ip db: # image: docker.io/mysql:8 # When running on ARM64 use MariaDB instead of MySQL image: docker.io/mariadb:10.4 # For auto DB backups comment out image and use the build block below # build: # context: ./config/mysql ports: - "3305:3306" restart: always env_file: env volumes: - ./docker/mysql/data:/var/lib/mysql:rw,delegated # remove comments for next 4 lines if you want auto sql backups #- ./docker/mysql/bak:/backups:rw #- ./config/mysql/backup-script:/etc/cron.daily/daily:ro #- ./config/mysql/backup-script:/etc/cron.weekly/weekly:ro #- ./config/mysql/backup-script:/etc/cron.monthly/monthly:ro networks: - invoiceninja #extra_hosts: # - "in5.localhost:192.168.0.124 " #host and ip networks: invoiceninja: ```

When I run podman-compose up -d, everything appears to launch correctly with no errors. But if I curl localhost:8003 from the remote machine, I just get the default nginx welcome page. And if I load http://raspberrypi.local:8003 in my laptop browser, I get an nginx 403 forbidden page.

I have commented out the extra_hosts sections because I just want to directly connect via IP address or avahi network name. But perhaps that's what I'm doing wrong?

n1smithy commented 4 months ago

Just my 2 cents as an IT-service-provider and single-person-business-man:

You are well consulted to ask an IT-specialist in your area for help with Docker (Compose) and Invoice Ninja – exspecially if you decide to expose your installation online. Otherwise consider using the clouded version if it wouldn't violate local laws.

I host Invoice Ninja by myself using Docker-compose and I think that the Docker-Compose-way is the best combination of the Docker-way to containerize software on Linux. And I'm glad that there's a lot of help here by the involved people within the forum and the github-pages!

However, it's a feature of Docker not to put all the services into a one and only container/image. If you prefer that, I would advise you to set up a virtual host as a dedicated server based on the recommended OS (Ubuntu 20.04 for now). But it all require you as a versed user who has some experiences in server-computing. If you are not, I repeat: You are well consulted by looking for an experienced IT-sepcialist who has some experience with Linux, Docker (Compose) and hopefully with Invoice Ninja, too.

AlexandreBonneau commented 1 month ago

But perhaps that's what I'm doing wrong?

If you see the default "Welcome to nginx!", even though you get the INFO success: scheduler entered RUNNING state, process has stayed up for > than 1 seconds (startsecs), showing in the logs, then make sure you updated the config/hosts file to something like localhost invoice.test, then try accessing the http(s)://invoice.test on your pc.

That part is easy to miss in the doc (I know I did..)