Open dennisdebel opened 8 months ago
Solved the 'postgresql' isn't an available database backend or couldn't be imported.
error by hard-coding the database engine in `Backend/services/settings.py' like so:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": os.environ.get("DATABASE_NAME"),
"USER": os.environ.get("DATABASE_USER"),
"PASSWORD": os.environ.get("DATABASE_PASSWORD"),
"HOST": os.environ.get("DATABASE_HOST"),
"PORT": os.environ.get("DATABASE_PORT")
}
}
Now I get the error that the database 'localhost' can not be found, which is correct. Somehow the settings in .env are not reaching this settings.py. Will hardcode the database name for now and do further testing.
Hi @dennisdebel,
Thanks for your feedback!
Sorry for the late reply. Looks like you're having problems with the .env
file, firebase storage, and the PostgreSQL database. Let me clarify a little bit for you.
.env
file.npm
first, then remember to keep an eye on the HOST URL configuration at Frontend/app/components/config.ts).About the .env
file, I will explain the first 3 attributes:
CREDENTIAL_JSON_FILE_NAME
: contains the path to the credential JSON file that you get from configuring Firebase cloud storage for your purpose.STORAGE_BUCKET_NAME
: This attribute specifies the name of a storage bucket to store files on Firebase cloud storage (in this project, we use it to store user's avatars, and their uploaded pdf files). Of course, you can find it in the project's setting on Google Cloud Console. it might be something like “my-awesome-bucket.”SECRET_KEY
: a Django project secret key.I hope this will help you explore our repo. If you have any concerns regarding our repository, feel free to ask, and we’ll do our utmost to assist you!
Thank you for the reply! I think I have the back-running after hard coding my .env variables in settings.py, all running locally (except firebase).
The frontend is still an issue. After manually installing nvm, node, npm, yarn, next, react, react-dom and fixing the dependency issues by adding the missing peer dependencies to package.json. The frontend installation does not work. Trying to build it manually in the dir reveals the possible error:
When running (as suggested to fix the BUILD_ID not found error below):
npm install
npm run build
I get the following error:
./app/history/page.tsx
73:33 Error: Missing "key" prop for element in iterator react/jsx-key
112:37 Error: Missing "key" prop for element in iterator react/jsx-key
/app/history/page.tsx
code looks a bit weird and cant spot the error unfortunately
Console history from docker compose:
=> ERROR [frontend 5/6] RUN yarn install && yarn start 435.4s
------
> [frontend 5/6] RUN yarn install && yarn start:
0.320 yarn install v1.22.19
0.361 [1/4] Resolving packages...
9.376 [2/4] Fetching packages...
420.0 [3/4] Linking dependencies...
423.4 [4/4] Building fresh packages...
434.4 success Saved lockfile.
434.4 Done in 434.12s.
434.6 yarn run v1.22.19
434.6 $ next start
434.9 [Error: ENOENT: no such file or directory, open '/translation-app-frontend/.next/BUILD_ID'] {
434.9 errno: -2,
434.9 code: 'ENOENT',
434.9 syscall: 'open',
434.9 path: '/translation-app-frontend/.next/BUILD_ID'
434.9 }
434.9 error Command failed with exit code 1.
434.9 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
failed to solve: process "/bin/sh -c yarn install && yarn start" did not complete successfully: exit code: 1
@nbtin Thank you so much for you instructions and explanation! I gave up using Docker and now running the frontend and backend seperately. The frontend seems to be working fine from the instructions in the Readme.md. Thank you so much for your time!
Two questions issues at the moment:
In the .env
file, How to get/set the SECRET_KEY: a Django project secret key
?
Getting the backend to work ends at this step python3 manage.py makemigrations account translation
when I get the following errors:
(env) user@userpc:~/Documents/translation_layoutrecovery/Backend$ python3 manage.py makemigrations account translation
Traceback (most recent call last):
File "/home/user/Documents/translation_layoutrecovery/Backend/manage.py", line 22, in <module>
main()
File "/home/user/Documents/translation_layoutrecovery/Backend/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/core/management/base.py", line 453, in execute
self.check()
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/core/management/base.py", line 485, in check
all_issues = checks.run_checks(
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/core/checks/registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/core/checks/urls.py", line 24, in check_resolver
return check_method()
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/urls/resolvers.py", line 494, in check
for pattern in self.url_patterns:
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/utils/functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/urls/resolvers.py", line 715, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/utils/functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/user/Documents/translation_layoutrecovery/Backend/services/urls.py", line 24, in <module>
path("", include("account.urls")), # Added account app
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/django/urls/conf.py", line 38, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/user/Documents/translation_layoutrecovery/Backend/account/urls.py", line 2, in <module>
from .views import Register, Login, Logout, GetUserData, UpdateProfile
File "/home/user/Documents/translation_layoutrecovery/Backend/account/views.py", line 28, in <module>
cred = credentials.Certificate(credential_json)
File "/home/user/Documents/translation_layoutrecovery/Backend/env/lib/python3.10/site-packages/firebase_admin/credentials.py", line 88, in __init__
raise ValueError(
ValueError: Invalid certificate argument: "None". Certificate argument must be a file path, or a dict containing the parsed file contents.
Thanks for your response before. As for the problems with next, the solution I indicated in error 2 #11 (modify docker-compose) seems to work. On the other hand, regarding your last question:
Thank you for the reply! Glad to see you got further! I cant get the json credentials to work. So strange, python can't find the file (checked name, path, permissions). Maybe I start with a fresh clone and work from there...
/EDIT
After a clean clone, the whole process was a lot smoother up until the same credentials error...
Dear! I am totally new with Docker and many of the technologies used here, sorry for that, trying to learn. I feel I got pretty far but still cannot run the image. What I did: adding to requirements.txt > 'networkx==3.1' (somehow the python version does not match with the latest networkx). Installing NVIDIA Container Toolkit, PostgreSQL (and making a database, user with password), making a new Firebase bucket and adding all credentials (and json) to the .env file (btw what is the SECRET_KEY, this is deprecated in firebase).
I am on Ubuntu 22.04.4 LTS.
Full log: