Is there a comparison of env variables between v4 and v5

I’m looking to migrate from v4 to v5 and while beeing busy installing v5 (via docker) I was wondering which of the env variables I can simply copy/paste from my v4 install.

here is my old .env file (btw. in v5 it seems to be called env without the . - did this change or am I supposed to copy the file after cloning the git repo?

# all .env variables are listed here:
# https://github.com/invoiceninja/invoiceninja/blob/master/.env.example
###
# DB config
MYSQL_DATABASE=invoiceninja
MYSQL_ROOT_PASSWORD=
# APP config
APP_ENV=production
APP_DEBUG=false
APP_URL=https://
APP_KEY=
APP_CIPHER=AES-256-CBC
# DB details for APP
DB_USERNAME=root
DB_PASSWORD=
DB_HOST=mysql
DB_DATABASE=invoiceninja
# Email config
MAIL_HOST=smtp.gmail.com
MAIL_DRIVER=smtp
MAIL_PORT=587
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME=""
MAIL_FROM_ADDRESS=
MAIL_USERNAME=
MAIL_PASSWORD=
# Proxy configuration
TRUSTED_PROXIES="172.17.0.0/16,somenetwork"
#Google Maps integration
GOOGLE_MAPS_ENABLED=true
GOOGLE_MAPS_API_KEY=
# Create a cookie to stay logged in
REMEMBER_ME_ENABLED=true
# Immediately expire cookie on the browser closing
SESSION_EXPIRE_ON_CLOSE=true
# The app automatically logs the user out after this number of seconds
AUTO_LOGOUT_SECONDS=1880
REQUIRE_HTTPS=true
# password for mobile app usage
API_SECRET=
# adding my phantomjs API key
# details: https://github.com/invoiceninja/invoiceninja/blob/master/docs/configure.rst#phantomjs
PHANTOMJS_CLOUD_KEY=''
# alternatively use a local instance
# https://www.invoiceninja.com/forums/topic/self-hosted-pdf-in-invoice-email-bad/#post-15319
#PHANTOMJS_BIN_PATH=/usr/local/bin/phantomjs
#PHANTOMJS_SECRET=

There are plenty of questions:

Oh, I noticed you have left the MYSQL variables inside docker-compose.yml - is there a particular reason why these have not moved to the env file?

environment:

  • MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword
  • MYSQL_USER=ninja
  • MYSQL_PASSWORD=ninja
  • MYSQL_DATABASE=ninja

and then I checked the hub: https://hub.docker.com/r/invoiceninja/invoiceninja

Those instructions seem more complete but are they for v4 or v5?

Hey there, environment variables mapping isn’t the same at v5. The best way would be to copy values manually.

If you’re using Invoice Ninja version 4, non-Docker, variables should be defined at the .env file.
For Invoice Ninja v5 it is the same unless you’re using the Docker, where it should be without the dot.

That’s just how Docker works.

To see all variables for version 5:

thanks for clarifying. I guess I messed up a bit with the env file. I was using v4 via docker and intend to do so again with v5.

My docker-compose.yml had used the .env file this way:

services:
  db:
    image: mysql:5
    container_name: invoiceninja_db
    env_file: .env

Thanks for this link, that was what i was looking for: https://github.com/invoiceninja/invoiceninja/blob/v5-develop/.env.example

Sure thing! Just copy the values of environment variables from docker-compose.yml (version 4) to env file for version 5. That should be fine. :+1:

thx. just wanted to mention that if you change docker-compose.yml with regards to app names/hostnames you have to edit config/nginx/in-vhost.conf and adapt this line with the correct hostname:

fastcgi_pass in-app:9000;

Getting errors like this when starting app (this is from the app container):

In Connection.php line 678:

  SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from inform
  ation_schema.tables where table_schema = ninja and table_name = accounts an
  d table_type = 'BASE TABLE')


In Exception.php line 18:

  SQLSTATE[HY000] [2002] No such file or directory

It seems like somehow the env variables I have set aren’t picked up. Or maybe some service name is hard-coded somewhere and hence the initial IN tables aren’t created.

Here is how I have adapted my docker-compose.yml I like renaming my services and adapting the container names as well as the hostnames:

  in-app:
    container_name: in-app
    hostname: in-app
    image: invoiceninja/invoiceninja:5
    env_file: env

  in-db:
    container_name: in-db
    hostname: in-db
    image: mysql:5
    env_file: env

This is the relevant env file part:

# DB config
MYSQL_DATABASE=invoiceninja
MYSQL_ROOT_PASSWORD=rootpass
MYSQL_PASSWORD=ninjapass
MYSQL_USER=ninja

# DB details for APP
DB_USERNAME=ninja
DB_PASSWORD=ninjapass
DB_HOST=in-db
DB_DATABASE=invoiceninja

Hm, this is weird. But, if this setup works for you, just go with it. However, if you think you may help others with the same problem, please open an issue on github.com/invoiceninja/dockerfiles & we’ll do our best to adapt & accept this if it can be replicated. Thanks :+1:

I am still struggling with this part. It looks like when the IN db is starting up it is lacking the correct permissions to write to docker/mysql/data

according to the instructions: https://github.com/invoiceninja/dockerfiles I started with

git clone https://github.com/invoiceninja/dockerfiles.git

so now dockerfiles/docker/mysql/data is all owned by root as I executed the git command as root.

after entering the db container with
docker exec -ti db bash
I did a id mysql command and found out the user ID of mysql is 999 so obviously that user ID has no permission.

How to fix this?

I think it’d be best for you to do this non-root. Docker should be able to operate as the non-root user just fine. Is there any reason for you to don’t use non-root user?

thanks but I see no difference.

lets say I am logged in as user ovi.
I do the git clone command as ovi, now all folders are owned by ovi.
I start IN as ovi, now all containers are running as user ovi.

The problem still persists that inside each IN container there are services which need the proper permissions to access the mounted volumes and I need to know which containers runs which services with which UUID/GUID

or am I missing something?

Um, really unsure haven’t seen this one before. Can you check is your user part of docker group?

@david can you help us with this?

I followed the instructions, please see the link I provided.

regarding docker group: if my user wasn’t in the docker group I couldn’t start the IN containers via docker-compose.yml :slight_smile: