Closed miguelcleon closed 6 years ago
@miguelcleon I just saw this. My apologies. I won't be able to work on this today, but I'll take a look tomorrow what's going on. Thanks. Does it work locally when you try to build the Docker image?
@lsetiawan ok, sounds good thanks. No I haven't gotten to work. I'm trying to run it on a VM and I ran out of space on it and it is taking a long time to expand the drive. I changed the host name sent to postgresql in the latest commit to this PR. that seems to be the latest error.
Now I get a different error in the docker log:
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Postgres is unavailable - sleeping
After looking at the code, I remember what I did. I separated the database from the actual application and use docker-compose to spin things up. See https://github.com/ODM2/ODM2-Admin/tree/master/docker/docker-deploy
This auto build the image. I guess the application docker file needs to be tweaked to be a stand alone rather than trying to attach to the non-existent database, which causes the error.
@lsetiawan so how was it attaching to the database before? I'm not understanding what broke. Thanks
Before it installs and spins up postgresql in the background.
Have you tried doing docker-compose up
?
@lsetiawan oh these settings files need to be updated https://github.com/ODM2/ODM2-Admin/blob/master/docker/docker-deploy/settings/
@lsetiawan oh these settings files need to be updated https://github.com/ODM2/ODM2-Admin/blob/master/docker/docker-deploy/settings/
Yes indeed.
forgot to change the name of this last commit
It seems like docker-compose should work but I keep getting:
odm2admindb | ERROR: database "odm2" already exists
odm2admindb | STATEMENT: CREATE DATABASE odm2;
maybe if I comment out https://github.com/ODM2/ODM2-Admin/blob/master/docker/odm2admin/wait-for-postgres.sh#L15
maybe if I comment out https://github.com/ODM2/ODM2-Admin/blob/master/docker/odm2admin/wait-for-postgres.sh#L15
That should work, but it's weird how "odm2" database already exist. hmm...
nope that didn't help
I needed to change the git clone branch in the dockerfile but now I get:
odm2admindb | FATAL: database "odm2" does not exist odm2adminapp | psql: FATAL: database "odm2" does not exist odm2admindb | FATAL: database "odm2" does not exist
so that CREATE DATABASE odm2;
needs to run the first time only in wait-for-postgres.sh
maybe it should not stop on error, like this I guess:
psql -v ON_ERROR_STOP=0 --host "$host" --username "postgres" -c "CREATE DATABASE odm2;"
@miguelcleon What's the status of this?
@lsetiawan seems like it works if I comment out:
psql -v ON_ERROR_STOP=1 --host "$host" --username "postgres" -c "CREATE DATABASE odm2;"
from here:
https://github.com/ODM2/ODM2-Admin/blob/master/docker/odm2admin/wait-for-postgres.sh#L15
but only in the local copy; if I comment it out in github then I get a no odm2 error:
odm2admindb | FATAL: database "odm2" does not exist
odm2adminapp | psql: FATAL: database "odm2" does not exist
odm2admindb | FATAL: database "odm2" does not exist
So this should only run the first time; maybe move it to the dockerfile?
I think it works now. Building dockerhub repo based on miguelcleon fork https://hub.docker.com/r/miguelcleon/odm2-admin/builds/
success! @lsetiawan maybe you could try running the docker container? https://hub.docker.com/r/miguelcleon/odm2-admin/ pinging @emiliom
@lsetiawan did you get a chance to try this?
Am I still composing up or simply run the docker image?
Try both. I had different issues in actually running the app in a web browser that I'm confused about.
I am having sql problem when creating the database using docker-compose
:
odm2adminapp | psql:/odm2adminDB.sql:30: ERROR: schema "admin" already exists
odm2admindb | ERROR: schema "admin" already exists
odm2admindb | STATEMENT: CREATE SCHEMA admin;
and getting
psql: could not translate host name "db" to address: Name or service not known
Postgres is unavailable - sleeping
psql: could not translate host name "db" to address: Name or service not known
Postgres is unavailable - sleeping
because the application doesn't map to db. I think might have to put a Database option to the docker image.
Are you using the django2 branch?
Yepp. And used your docker image.
Ok I guess we might have to put a Database option to the docker image
@lsetiawan so how do we add the database option to the docker image? I've played around with this but have not had success.
@miguelcleon I suggest using Docker ENV This sets the system environment variables for docker. So when running the images, you can do docker run -e DBHOST=123.23.123.12 -e DBUSER=someone -e DBPASSWORD=blahblah ...
Then id the development.py settings python file, should be able to read from os.environ
with those credentials and host.
@lsetiawan I made two minor changes to the dockerfile and I'm trying to run the build on dockerhub but I'm not really sure what I'm doing. https://hub.docker.com/r/odm2/odm2-admin/builds/