open-eats / OpenEats

:pizza: Self Hosted Recipe Management App :hamburger:
https://open-eats.github.io/
MIT License
670 stars 102 forks source link

Fresh Non-Docker Install unable to login #109

Open MrCarter2959 opened 4 years ago

MrCarter2959 commented 4 years ago

Seems like the non-docker install guide found here https://github.com/open-eats/OpenEats/blob/master/docs/Running_the_App_Without_Docker.md isn't fully completed. It leaves out how to populate the database with defaults such as first user and static data. I've tried running python3 manage.py createsuperuser and it comes back with error's about "Table 'djano_content_type' already exists"

Any ideas?

sailorbob134280 commented 4 years ago

Having a similar problem. I'm able to create superusers, but they aren't able to log in.

NateTheSage commented 4 years ago

I happened to figure out what the issue was regarding my lack of database population, so hopefully this will work for you guys. (My initial issue was I had skipped a step regarding prod-entrypoint.sh in which you replace the /code/manage.py with what's in the Running without Docker wiki on accident, whoops!).

There's a step that is not mentioned in the wiki that involves modifying the settings.py in the base directory. You have to make it match your .env database information in order to get your database populated, otherwise you'll get an unclear error about not being able to connect to 'db'. I did python3 manage.py createsuperuser after I figured this out and it worked perfectly, login included.

You'll want to look for this location in settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': os.environ.get('MYSQL_DATABASE', 'openeats'),
        'USER': os.environ.get('MYSQL_USER', 'root'),
        'PASSWORD': os.environ.get('MYSQL_ROOT_PASSWORD', ''),
        'HOST': os.environ.get('MYSQL_HOST', 'db'),
        'PORT': os.environ.get('MYSQL_PORT', '3306'),
        'OPTIONS': {
            'charset': 'utf8mb4'
        },
        'TEST': {
            'NAME': os.environ.get('MYSQL_TEST_DATABASE', 'test_openeats')
        }
    }
}

The database can and should operate without those naughty root credentials there, so put in whatever you put in your .env. The next time you restart your API, the database should self-populate. If not, run it manually and kill your gunicorn process with a Control-C.

This was done on Debian 10 (in a very hacky fashion since Node 8 is not in support anymore). I'm going to see about getting the wiki steps modified to include this info, particularly steps on a more modern operating system, as I think the steps seem to think the user is on Debian 8, which is now oldoldstable.

NateTheSage commented 4 years ago

There we are, pull request is in to include the new step. It's a bit hacky, but if someone wants to do it on Debian 10, it is in fact possible, with some elbow grease. :sweat_smile:

RyanNoelk commented 4 years ago

Thanks of taking the time to update the docs :)

Please feel free to create PRs that update these docs in the future. I run everything in a docker container so I'd never needed/updated these docs.

NateTheSage commented 4 years ago

Not a problem! The only suggestion I can make is ensuring your Node is up to date. Getting that stuff to work when it's out of date and you're not a Node guru is an exercise in patience. :stuck_out_tongue_winking_eye: