Hi Sérgio,

I can reproduce your problem by deleting the database in the copr_database_1 container and then running init-database.sh in the frontend container. You are missing the relations in copr_database_1. You can download the database dump here https://copr.fedorainfracloud.org/db_dumps/. Copy the extracted db dump into copr_database_1 and run psql coprdb < your_dump. Or try to delete the docker containers and images and then run docker-compose up -d once again. After successful completion, the relations in copr_database_1 should be created, and after running init-database.sh, it should show text that some of the chroots that the script is trying to create already exist.

Silvie


On 1/4/22 00:03, Sérgio Basto wrote:
Hi, 
I started to build my own copr , I follow
the http://frostyx.cz/posts/copr-docker-compose-without-supervisord 

but can't pass the init-database.sh [1], I'm using
https://pagure.io/copr/copr.git 30 dec 2021 commit (f18faf4f)

any tip ? 


[1]
docker exec -it copr_frontend_1 bash
cd /usr/share/copr/coprs_frontend/ && copr-frontend create-db --alembic
alembic.ini
[2022-01-03 23:01:38,665] INFO in log: logging configuration finished
/usr/share/copr/coprs_frontend/coprs/models.py:2445: SAWarning:
relationship 'Build.package' will copy column package.id to column
build.package_id, whichconflicts with relationship(s): 'Package.builds'
(copies package.id to build.package_id). If this is not the intention,
consider if these relationships should be linked with back_populates,
or if viewonly=True should be applied to one or more if they are read-
only. For the less common case that foreign keyconstraints are
partially overlapping, the orm.foreign() annotation can be used to
isolate the columns that should be written towards.   To silence this
warning, add the parameter 'overlaps="builds"' to the 'Build.package'
relationship. (Background on this error at:
https://sqlalche.me/e/14/qzyx)
db.session.add(DistGitInstance(
Traceback (most recent call last):
File "/usr/lib64/python3.10/site-packages/sqlalchemy/engine/base.py",
line 1802, in _execute_context
self.dialect.do_execute(
File "/usr/lib64/python3.10/site-
packages/sqlalchemy/engine/default.py", line 732, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.UndefinedTable: relation "dist_git_instance" does not
exist
LINE 1: INSERT INTO dist_git_instance (name, clone_url, clone_packag...
^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/bin/copr-frontend", line 125, in <module>
app.cli()
File "/usr/lib/python3.10/site-packages/click/core.py", line 1137, in
__call__
return self.main(*args, **kwargs)
File "/usr/lib/python3.10/site-packages/click/core.py", line 1062, in
main
rv = self.invoke(ctx)
File "/usr/lib/python3.10/site-packages/click/core.py", line 1668, in
invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3.10/site-packages/click/core.py", line 1404, in
invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3.10/site-packages/click/core.py", line 763, in
invoke
return __callback(*args, **kwargs)
File "/usr/bin/copr-frontend", line 99, in wrapper
sys.exit(bool(function(*args, **kwargs)))
File "/usr/share/copr/coprs_frontend/commands/create_db.py", line 18,
in create_db
db.create_all()
File "/usr/lib/python3.10/site-packages/flask_sqlalchemy/__init__.py",
line 1094, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/usr/lib/python3.10/site-packages/flask_sqlalchemy/__init__.py",
line 1086, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "/usr/lib64/python3.10/site-packages/sqlalchemy/sql/schema.py",
line 4785, in create_all
bind._run_ddl_visitor(
File "/usr/lib64/python3.10/site-packages/sqlalchemy/engine/base.py",
line 3117, in _run_ddl_visitor
conn._run_ddl_visitor(visitorcallable, element, **kwargs)
File "/usr/lib64/python3.10/site-packages/sqlalchemy/engine/base.py",
line 2113, in _run_ddl_visitor
visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
File "/usr/lib64/python3.10/site-packages/sqlalchemy/sql/visitors.py",
line 524, in traverse_single
return meth(obj, **kw)
File "/usr/lib64/python3.10/site-packages/sqlalchemy/sql/ddl.py", line
849, in visit_metadata
self.traverse_single(
File "/usr/lib64/python3.10/site-packages/sqlalchemy/sql/visitors.py",
line 524, in traverse_single
return meth(obj, **kw)
File "/usr/lib64/python3.10/site-packages/sqlalchemy/sql/ddl.py", line
915, in visit_table
table.dispatch.after_create(
File "/usr/lib64/python3.10/site-packages/sqlalchemy/event/attr.py",
line 343, in __call__
fn(*args, **kw)
File "/usr/share/copr/coprs_frontend/coprs/models.py", line 2451, in
insert_fedora_distgit
db.session.commit()
File "<string>", line 2, in commit
File "/usr/lib64/python3.10/site-packages/sqlalchemy/orm/session.py",
line 1431, in commit
self._transaction.commit(_to_root=self.future)
File "/usr/lib64/python3.10/site-packages/sqlalchemy/orm/session.py",
line 829, in commit
self._prepare_impl()
File "/usr/lib64/python3.10/site-packages/sqlalchemy/orm/session.py",
line 808, in _prepare_impl
self.session.flush()
File "/usr/lib64/python3.10/site-packages/sqlalchemy/orm/session.py",
line 3363, in flush
self._flush(objects)
File "/usr/lib64/python3.10/site-packages/sqlalchemy/orm/session.py",
line 3502, in _flush
with util.safe_reraise():
File "/usr/lib64/python3.10/site-
packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
compat.raise_(
File "/usr/lib64/python3.10/site-packages/sqlalchemy/util/compat.py",
line 207, in raise_
raise exception
File "/usr/lib64/python3.10/site-packages/sqlalchemy/orm/session.py",
line 3463, in _flush
flush_context.execute()
File "/usr/lib64/python3.10/site-
packages/sqlalchemy/orm/unitofwork.py", line 456, in execute
rec.execute(self)
File "/usr/lib64/python3.10/site-
packages/sqlalchemy/orm/unitofwork.py", line 630, in execute
util.preloaded.orm_persistence.save_obj(
File "/usr/lib64/python3.10/site-
packages/sqlalchemy/orm/persistence.py", line 244, in save_obj
_emit_insert_statements(
File "/usr/lib64/python3.10/site-
packages/sqlalchemy/orm/persistence.py", line 1221, in
_emit_insert_statements
result = connection._execute_20(
File "/usr/lib64/python3.10/site-packages/sqlalchemy/engine/base.py",
line 1614, in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
File "/usr/lib64/python3.10/site-packages/sqlalchemy/sql/elements.py",
line 325, in _execute_on_connection
return connection._execute_clauseelement(
File "/usr/lib64/python3.10/site-packages/sqlalchemy/engine/base.py",
line 1481, in _execute_clauseelement
ret = self._execute_context(
File "/usr/lib64/python3.10/site-packages/sqlalchemy/engine/base.py",
line 1845, in _execute_context
self._handle_dbapi_exception(
File "/usr/lib64/python3.10/site-packages/sqlalchemy/engine/base.py",
line 2026, in _handle_dbapi_exception
util.raise_(
File "/usr/lib64/python3.10/site-packages/sqlalchemy/util/compat.py",
line 207, in raise_
raise exception
File "/usr/lib64/python3.10/site-packages/sqlalchemy/engine/base.py",
line 1802, in _execute_context
self.dialect.do_execute(
File "/usr/lib64/python3.10/site-
packages/sqlalchemy/engine/default.py", line 732, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable)
relation "dist_git_instance" does not exist
LINE 1: INSERT INTO dist_git_instance (name, clone_url, clone_packag...
^