(08-03-2020, 04:54 PM)Diego Wrote: Just checked your git repo and I think the problem is in:
docker-compose.yml
you set two env variables:
TACTIC_INSTALL_DIR: '/home/apache/tactic'
TACTIC_DATA_DIR: '/home/apache/tactic_data'
if you check /usr/local/lib/python3.7/site-packages/tacticenv/__init__.py tey are used to setup the sys.path
the should be:
TACTIC_INSTALL_DIR: '/opt/tactic/tactic'
TACTIC_DATA_DIR: '/opt/tactic/tactic_data'
Sorry, I started working in a new branch -- but I also removed those env variables. Now I feel like there's progress:
Code:
...
tactic_1 | File "/usr/local/lib/python3.7/site-packages/psycopg2/__init__.py", line 127, in connect
tactic_1 | conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
tactic_1 | psycopg2.OperationalError: FATAL: database "sthpw" does not exist
tactic_1 |
docker-tactic_tactic_1 exited with code 1
(08-03-2020, 04:54 PM)Diego Wrote: Regarding the Docker Volumes, yes they are used to keep the status when you re-deploy docker images and they are very useful for upgrading an image, but...
If you launch the tactic installation in the dockerfile it will try to create the sthpw db inside the same image and fail.
You should install tactic without the db creation (--install_db false) but then you will have to write some code in the docker entry point to check if the DB exists and cerate it if it doesn't we should add an option in the install.py to just create the sthpw db.
This is what I'm doing to make the install work for the image. For database creation there's init scripts provided by the popular db images, such as postgres. We can use an sql file placed at ./postgres/data/ to create the sthpw db. This file is ingested during postgres container creation. I've used this feature on other projects with success (mysql/maraiadb.) Unfortunately I've not been able to locate init sql for Tactic.
(08-03-2020, 04:54 PM)Diego Wrote: Still bot tactic and the install.py script use os.system() to launch some postgres utilities like createdb and psql to create new dbs for projects (see src/pyasm/search/database_impl.py) which will fail if the database is running on a different machine or docker image.
One of the changes we could make is to have the database host be read from an environment variable, TACTIC_DBHOST for example. That way, in the docker-compose.yaml we can do: TACTIC_DBHOST: db
or whatever the container name is set to under services. I also need to add the postgres client to the tactic image.
(08-03-2020, 04:54 PM)Diego Wrote: We should try to solve these problems in tactic first.
I started my docker image mainly as a quick debug tool to test changes in the tactic code in a clean environment to avoid the "works on my machine" problem, this is why I never developed e better/proper image, but I guess we could join forces with Remko to add a Dockerfile/docker-compose.yml directly into the tactic codebase, for them to become "official"
In my production environment I use a docker image for postgres but I prefer to run tactic in a python virtualenv.
That's what I like about the flexibility of Docker and the rapid iteration it can provide. I appreciate your comments! If you're looking at my messy code, look at the frompython branch: https://github.com/lyonritchie/docker-ta...frompython :-)