open-eats / OpenEats

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

New Install - Database not populated and API not communicating? #151

Open rlglenn opened 3 years ago

rlglenn commented 3 years ago

New install on FreeBSD 12.2 jail. I'm not sure if it is a permissions problem or environment variable problem or both or something else altogether, can browse to first page, but nothing populated and /admin and /api get 404's. /browse, /random, /recipes and /news are basically blank besides header and footer. /login shows textboxes and button, but no action. It looks like css and js work, just not API. Logs show no errors or point to anything useful. Database has tables but no sample data (I assumed it had dummy recipes, etc. but none show.) Can anyone point me in a direction? How can I otherwise populate database to troubleshoot in that direction? Is there a schema or dump I can use? I would like to provide documentation to steps I took once completed for everyone's edification.

Drudoo commented 3 years ago

Go into your database container docker exec -it openeats_db_1 /bin/sh and check that the database is there (SHOW DATABASES;) if the openeats db isn't there, create it (CREATE DATABASE openeats;).

Then go into your api container docker exec -it openeats_api_1 /bin/sh and run:

python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser

Then you can populate it with sample data using

python manage.py loaddata course_data.json
python manage.py loaddata cuisine_data.json
python manage.py loaddata news_data.json
python manage.py loaddata recipe_data.json
python manage.py loaddata ing_data.json

And finally restart your docker containers.

rustymyers commented 3 years ago

The first command doesn't seem to do what I expected:

$ docker exec -it openeats_db_1 /bin/sb
OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "/bin/sb": stat /bin/sb: no such file or directory: unknown

I'm having the same issues. I've been attempting to set up and following directions, the openeats.sql database isn't created. Running quickstart a second time creates an empty openeats.sql (0 bytes).

Starting OpenEats
==================
Taking a database backup (saving as openeats.sql)...
mysqldump: Got error: 1045: "Access denied for user 'root'@'localhost' (using password: YES)" when trying to connect

I can connect to the container with docker exec -it openeats_db_1 /bin/su, but I can't run the mysql command:

$ /opt/OpenEats# docker exec -it openeats_db_1 /bin/su
root@4ddfb2405f99:/# mysql -uroot -proot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

Any thoughts? I keep erasing everything and staring fresh to get the same issue.

Updated: Changed mysql to correct command using the standard password

Drudoo commented 3 years ago

The first command should be /bin/sh. That was a typo from my side.

Updated: Changed mysql to correct command using the standard password

Did you get it working them?

When you get the access denied it is because the password is wrong.

rustymyers commented 3 years ago

No, I keep trying to erase all the containers and start over to get a db instance with the correct password...

docker stop openeats_web_1 openeats_nginx_1 openeats_api_1 openeats_db_1 ;  docker rm openeats_web_1 openeats_nginx_1 openeats_api_1 openeats_db_1

I clone the repo...

git clone https://github.com/open-eats/OpenEats.git

I create the env_prod.list

# Database config
MYSQL_DATABASE=openeats
MYSQL_ROOT_PASSWORD=root

# Django config
API_URL=0.0.0.0:8000
API_PORT=8000
DJANGO_SECRET_KEY=sdfsadfas32e98zsdvhhsnz6udvbksjdhfi4galshjfg
DJANGO_SETTINGS_MODULE=base.settings
DJANGO_DEBUG=True
ALLOWED_HOST=myhost.org,10.0.0.10
HTTP_X_FORWARDED_PROTO=true

# Node config
NODE_ENV=production
NODE_URL=localhost:8080
NODE_API_URL=http://myhost.org:7000
NODE_LOCALE=en

Then creating the docker-prod.override.yml...

version: '2.3'
services:
  nginx:
    ports:
      - "7000:80"
    restart: always
  api:
    restart: always
  web:
    restart: on-failure
  db:
    restart: always

I am then starting everything with ./quick-start.py.

./quick-start.py
==================
Downloading Images
==================
latest: Pulling from openeats/openeats-api
Digest: sha256:7d73944dc653a2781c566055c3ecd5c4d126766e256dc27dbcc36c37fae62b9a
Status: Image is up to date for openeats/openeats-api:latest
docker.io/openeats/openeats-api:latest
latest: Pulling from openeats/openeats-web
Digest: sha256:f49139cd0daa83a3420c7993c080e398c58de327032dbfaf26323ea1b4c17526
Status: Image is up to date for openeats/openeats-web:latest
docker.io/openeats/openeats-web:latest
latest: Pulling from openeats/openeats-nginx
Digest: sha256:d30864b7f37f6ad399d97f00e8f07fcef26256cf4c75facfab6f1c7517a1b117
Status: Image is up to date for openeats/openeats-nginx:latest
docker.io/openeats/openeats-nginx:latest
==================
Starting OpenEats
==================
Creating the DB. This may take a minute...
Creating openeats_db_1 ... done
Recreating openeats_db_1 ... done
Creating openeats_api_1  ... done
Creating openeats_web_1  ... done
Creating openeats_nginx_1 ... done
App started. Please wait ~30 seconds for the containers to come online.

After this, there is no openeats.sql stat base int he OpenEats folder. I then attempt to start mysql on the db container, as shown in my previous post it fails to connect with the default password of 'root'.

I presume this is why the database is never created, then the backup process creates an empty one when running QuickStart again? Do I have the correct default password?

Drudoo commented 3 years ago

Are you also deleting your docker volumes? Something like docker volume rm openeats_database.

Try and switch mysql image to linuxserver/mariadb.

See my comment here https://github.com/open-eats/OpenEats/issues/143#issuecomment-861570919 about running it from scratch.

rustymyers commented 3 years ago

I was not deleting the volume... I was not aware of volumes, I have more to learn about Docker! :)

Your comment helped and I was able to get into mysql with the default password and create the database. So, now I just have to get the API to talk to the front end...

Thanks!

rustymyers commented 3 years ago

@rlglenn Did you get the install to work?

rlglenn commented 3 years ago

@rlglenn Did you get the install to work?

I was able to create the database and populate it, but the API is still a no-go and the website is basically blank.

Also, I'm not using docker if that wasn't clear. This is all on one instance of a BSD jail.

rustymyers commented 3 years ago

Are you following the guide on running without docker? https://github.com/open-eats/OpenEats/blob/master/docs/Running_the_App_Without_Docker.md

Can you post the instructions you have written to this point so we can try to reproduce and test?

It may also be working and just have no data. Can you navigate to the /admin page?

rlglenn commented 3 years ago

I did follow the guide, but some things didn't work so I had to improvise, if I recall correctly. The database is populated so the loaddata scripts work, and I could navigate to admin login page, but not log in. I will attempt to recreate since it has been so long since I last tried and will post it all here.

rlglenn commented 3 years ago

In the best effort to keep diversions to a minimum, I will post what I did to set up, and only go as far as when I started to experience problems:

Jail setup

Release: 12.2-RELEASE
IPv4 Address = 172.16.0.2/30
Default Router: 172.16.0.1

NAT port forwarding:
Jail Port Number: 80
Host Port Number: 8099

Mount point:
/mnt/<your pool>/<your dataset name>/openeats -> /mnt/<your pool>/iocage/jails/mysql/root/var/db/mysql

Install Dependencies

pkg install git curl openssl python3 python37 py37-pip openjpeg node14 npm-node14 apache24

Database

pkg install mariadb105-server
chown -R mysql:mysql /var/db/mysql/

sysrc mysql_enable=yes
service mysql-server start
mysql_secure_installation

Create openeats database

At this point there is no data in the database, of course.

Continuing onto Set up the OpenEats-api from https://github.com/open-eats/OpenEats/blob/master/docs/Running_the_App_Without_Docker.md The MYSQL_ROOT_PASSWORD is confusing

I had to change the group and exec path in /opt/openeats/openeats-api/base/gunicorn_start.sh and add a line to collect the pid.

No systemd so had to setup rc.d script

chmod +x /usr/local/etc/rc.d/openeats
chmod +x /opt/openeats/openeats-api/base/prod-entrypoint.sh
sysrc openeats_enable=yes
service openeats start

Since the (.) command isn't available in csh, use bash

/usr/local/bin/bash
. ./.env
exit

Install the dependecies node@v14.16.1 yarn@1.22.10

After installing above ,when I run/opt/openeats/openeats-web/node_modules/yarn/bin/yarn start I get: Module build failed: Error: Cannot find module 'node-sass' error Command failed with exit code 1.

Even tough I followed the steps on Running_the_App_Without_Docker.md. After investigating, I see that node-sass is not installed

# npm list node-sass
OpenEats@1.0.0 /opt/openeats/openeats-web
└── (empty)

There is also a warning/err that peer deps ajv, react and fsevents are missing.

So at this point, should I clone node-sass from https://github.com/sass/node-sass.git and try building them again? What about the other 3 deps it is complaining about?

After we answer that, I will go on to posting the apache web config and report what happens then. Keep in mind that this is NAT'ed and the port is forwarded. I can also post config file contents if need be.