I dont want to git clone the invoiceninja/invoiceninja repository every time. So i just went to docker and built this bare minimal docker-compose out of the docker run command. After i do docker compose up
I am never able to access the app via localhost. What am i missing here?
docker-compose.yml
version: '3.7'
services:
db:
container_name: db
image: mariadb:latest
restart: always
networks:
- invoiceninja
env_file:
- .secrets/invoiceninja.env
invoiceninja:
container_name: invoiceninja
image: invoiceninja/invoiceninja:latest
ports:
- 7777:9000
restart: always
volumes:
- ./invoiceninja/public:/var/app/public:rw,delegated
- ./invoiceninja/storage:/var/app/storage:rw,delegated
networks:
- invoiceninja
env_file:
- .secrets/invoiceninja.env
depends_on:
- db
networks:
invoiceninja:
.secrets/invoiceninja.env
MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword
MYSQL_DATABASE=ninja
MYSQL_USER=ninja
MYSQL_PASSWORD=privacyStuff
DB_TYPE=mysql
DB_STRICT=false
DB_HOST=db
DB_PORT=3306
DB_DATABASE=ninja
DB_USERNAME=ninja
DB_PASSWORD=privacyStuff
TZ=Europe/Berlin
APP_KEY=base64:.....
APP_URL=http://localhost:7777
APP_ENV=production
APP_DEBUG=0
APP_CIPHER=AES-256-CBC
I don’t believe that you can run Invoiceninja without a webserver in it’s own service in the compose stack… as documented in the official docker-compose.yml from the GitHub repo https://github.com/invoiceninja/dockerfiles/blob/master/docker-compose.yml
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
ports:
- "80:80"
networks:
- invoiceninja
extra_hosts:
- "in5.localhost:192.168.0.124 " #host and ip
app:
image: 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: mysql:8
# When running on ARM64 use MariaDB instead of MySQL
# image: 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:
Also you don’t need to git clone nor pull I have just made my .env and docker-compose.yml + the bindings (with permission modifications) and that runs fine also at updates I only do a re-pull from dockerhub and all works as it should.
1 Like
Do you mind sharing only the docker-compose you have please. I am trying the default docker-compose in my windows machine and I am getting weird errors only.
@jenishngl
Okay I don’t have any experience with docker on windows, so this might not have anything to do with it.
- Is the volumes that are bind into your containers reference correctly?
- Have to been able permissions to do make the equivalate of “chmod 755 docker/app/public”
- Also set the owner to the equivalate of “sudo chown -R 1500:1500 docker/app”
Otherwise maybe use docker volumes to let UNIX based filesystem to the “storage” and “public” app persistent folders.
You write that your don’t what to git clone / pull but you need to do all other steps still and just make all files, folders and configs manual then (nicely documented in the README docker-compose section on dockerfiles repo.
Also have you made to app-key with docker run?
docker run --rm -it invoiceninja/invoiceninja php artisan key:generate --show
Save the docker-compose.yml in your dedicated InvoiceNinja folder together with the environment variable file env (and remember to modify with your docker run app-key and maybe secure creds). Now you also need to make some subdirs with config files first the NGINX config need to locate in config/nginx/in-host.conf and then the Host config config/hosts and the rest is not needed. Lastly you need to have the following subfolder docker/app/public and docker/app/storage in the same location as the compose and env file (this is also where invoiceninja/invoiceninja - 1500:1500 need to have ownership and permissions set).
Otherwise to come closer to the problem please post what the docker logs returns?
I have InvoiceNinja running in docker compose smoothly using this guide: https://youtu.be/xo6a3KtLC2g
1 Like