Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: app is already configured, backup then delete the .env file to re-run the setup #238

Closed
Rustymage opened this issue Dec 23, 2020 · 14 comments

Comments

@Rustymage
Copy link

Rustymage commented Dec 23, 2020

Ubuntu 20.04.

Running a new setup following the instructions and I get the following error:

Error: app is already configured, backup then delete the .env file to re-run the setup

Where is the .env? I haven't added one...

Here is the docker-compose.yml

version: '3.7'

services:
  server:
    container_name: InvoiceNinja_nginx
    image: nginx
    restart: always
    environment: 
      - APP_URL=https://URL.co.uk
    volumes:
      # Vhost configuration
      - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/default.conf:ro

      # Configure your mounted directories, make sure the folder 'public' and 'storage'
      # exist, before mounting them
      - ./public:/var/www/app/public
      - ./storage:/var/www/app/storage
      # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      # - ./docker/app/public:/var/www/app/public:rw,delegated
      # - ./docker/app/storage:/var/www/app/storage:rw,delegated
    depends_on:
      - app
    # Run webserver nginx on port 80
    # Feel free to modify depending what port is already occupied
    ports: 
      - "8000:80"
      - "4433:443"
    networks:
      - invoiceninja

  app:
    image: invoiceninja/invoiceninja:alpine-4
    container_name: InvoiceNinja_app
    restart: always
    environment: 
      - APP_URL=https://URL.co.uk
      - APP_KEY=XXXXXXX
      - MULTI_DB_ENABLED=false
      - DB_HOST=db
      - DB_USERNAME=ninja
      - DB_PASSWORD=password123
      - DB_DATABASE=ninja
      - REQUIRE_HTTPS=true
      - MAIL_HOST=smtp-mail.outlook.com
      - MAIL_USERNAME=email@outlook.com
      - MAIL_PASSWORD=password
      - MAIL_DRIVER=smtp
      - MAIL_FROM_NAME="name"
      - MAIL_FROM_ADDRESS=email@outlook.com
      - TRUSTED_PROXIES="*"
      - REQUIRE_HTTPS=false
    volumes:
      # Configure your mounted directories, make sure the folder 'public' and 'storage'
      # exist, before mounting them
      -  ./public:/var/www/app/public
      -  ./storage:/var/www/app/storage
      # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      # - ./docker/app/public:/var/www/app/public:rw,delegated
      # - ./docker/app/storage:/var/www/app/storage:rw,delegated
    depends_on:
      - db
    networks: 
      - invoiceninja  

  db:
    image: mysql:5
    container_name: InvoiceNinja_db
    restart: always
    environment: 
      - MYSQL_ROOT_PASSWORD=password123
      - MYSQL_USER=ninja
      - MYSQL_PASSWORD=password123
      - MYSQL_DATABASE=ninja
    volumes:
      - ./mysql-data:/var/lib/mysql:rw
      # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      # - ./docker/mysql/data:/var/lib/mysql:rw,delegated
    networks:
      - invoiceninja

  # THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5.
  cron:
     container_name: InvoiceNinja_cron
     image: invoiceninja/invoiceninja:alpine-4
     volumes:
       -  ./storage:/var/www/app/storage
       -  ./logo:/var/www/app/public/logo
       -  ./public:/var/www/app/public
     entrypoint: |
       /bin/sh -c 'sh -s <<EOF
       trap "break;exit" SIGHUP SIGINT SIGTERM
       sleep 300s
       while /bin/true; do
         ./artisan ninja:send-invoices
         ./artisan ninja:send-reminders
         sleep 1d
       done
       EOF'
     networks:
       - invoiceninja

#volumes:
#  mysql-data:
#  public:
#  storage:
  # This is needed for letting th cron run correctly
#  logo:

networks:
  invoiceninja:

I can't figure this out as the logs don't appear to help...

Thanks in advance!

@turbo124
Copy link
Member

Is there a reason you have uncommented the V4 section of the docker-compose?

@Rustymage
Copy link
Author

Is there a reason you have uncommented the V4 section of the docker-compose?

Ye - because I want invoice ninja 4, not 5 (it's not working well for me).

I was following this wiki:

https://github.com/invoiceninja/dockerfiles/wiki

@Rustymage
Copy link
Author

I have tried to install on a fresh system but get the same issue.

At this current time I'm stuck and wonder if the v4 docker install is broken.

@Rustymage
Copy link
Author

To get this to work I had to use image: invoiceninja/invoiceninja:alpine-4.5.18 and the .env issues disappeared.

@electronick86
Copy link

I try to use the v4 and have exactly the same issue

@Rustymage
Copy link
Author

To get this to work I had to use image: invoiceninja/invoiceninja:alpine-4.5.18 and the .env issues disappeared.

@electronick86 - did you try this?

@electronick86
Copy link

Yes, and then I have 502 Bad Gateway errors...

@Rustymage
Copy link
Author

Yes, and then I have 502 Bad Gateway errors...

Can you share your compose file please? I can try to help.

@electronick86
Copy link

thanks @Rustymage

I'm working behing traefik reverse proxy.

I use the same labels with IN5 with traefik and it works.

version: '3.7'

services:
  server:
    image: 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
      # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      - ./docker/app/public:/var/www/app/public:rw,delegated
      - ./docker/app/storage:/var/www/app/storage:rw,delegated
    depends_on:
      - app

    networks:
      - invoiceninja
      - traefik-web
    labels:
      - "traefik.frontend.rule=Host:ivs4.xxxx.be"
      - "traefik.enable=true"
      - "traefik.port=80"
      - "traefik.frontend.entryPoints=http,https"
#      - "traefik.frontend.redirect.entryPoint=https"
#      - "traefik.frontedn.redirect.permanent=true"
      - "traefik.docker.network=traefik-web" 
    extra_hosts:
      - "in5.localhost:192.168.0.124 " #host and ip

  app:
    image: invoiceninja/invoiceninja:alpine-4.5.18
    env_file: env
    restart: always
    volumes:
      # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      - ./config/hosts:/etc/hosts:ro
      - ./docker/app/public:/var/www/app/public:rw,delegated
      - ./docker/app/storage:/var/www/app/storage:rw,delegated
    depends_on:
      - db
    networks: 
      - invoiceninja  
    extra_hosts:
      - "in5.localhost:192.168.0.124 " #host and ip

  db:
    image: mysql:5
    ports:
      - "3305:3306"
    restart: always
    environment: 
      - MYSQL_ROOT_PASSWORD=dddd
      - MYSQL_USER=ninja
      - MYSQL_PASSWORD=ninja
      - MYSQL_DATABASE=ninja
    volumes:
      # you may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
      - ./docker/mysql/data:/var/lib/mysql:rw,delegated
    networks:
      - invoiceninja
    extra_hosts:
      - "in5.localhost:192.168.0.124 " #host and ip



  # THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5.
  cron:
    image: invoiceninja/invoiceninja:alpine-4.5.18
    volumes:
      - ./docker/app/public:/var/www/app/public:rw,delegated
      - ./docker/app/storage:/var/www/app/storage:rw,delegated
      - ./docker/app/public/logo:/var/www/app/public/logo:rw,delegated
    depends_on:
      - app
    entrypoint: |
       /bin/sh -c 'sh -s <<EOF
       trap "break;exit" SIGHUP SIGINT SIGTERM
       sleep 300s
       while /bin/true; do
         ./artisan ninja:send-invoices
         ./artisan ninja:send-reminders
         sleep 1d
       done
       EOF'
    networks:
      - invoiceninja


networks:
  invoiceninja:
  traefik-web:
    external: true

env file:

APP_URL=http://ivs.xxxx.be/
APP_KEY=base64:xxxx=
APP_DEBUG=false
MULTI_DB_ENABLED=false
DB_HOST1=db
DB_USERNAME1=ninja
DB_PASSWORD1=ninja
DB_DATABASE1=ninja

#this is a system variable please do not remove
IS_DOCKER=true


TRUSTED_PROXIES='10.0.0.0/8,172.16.0.0/12,192.168.0.0/16'

@Rustymage
Copy link
Author

What does - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro look like?

@electronick86
Copy link

I think I didn't do any edit in the file.

I check from the nginx container, I can "ping app" so the resolution is correct to the correct container.

server {
    listen 80 default_server;
    server_name _;

    root /var/www/app/public/;
    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }
}

@Rustymage
Copy link
Author

Rustymage commented Jan 26, 2021

The only difference I can see is the fact you don't have the following:

server {
    listen 80 default_server;
    server_name ivs.xxxx.be;

and
APP_KEY=xxxx

I use an NGINX proxy so I can't comment on traefik.

Other than that, I can't really help. Good to know if the above helps though.

@electronick86
Copy link

I realise that the uid of invoiceininja is 1000 with 4.5.18 and 1500 with 4.5.30

@electronick86
Copy link

with 4.5.18, problems with the permissions due to wrong uid.

switch back to 4.5.30 and follow this : #266 (comment)

Now everything is ok. So I suspect a problem with the migrations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants