ODM2 / CZ-Manager

CZ Manager (formerly ODM2 Admin) is an application for site level data management of environmental observations using Observation Data Model 2 (ODM2) for documentation and a detailed walkthrough see:
http://odm2.github.io/CZ-Manager
MIT License
9 stars 12 forks source link

Docker Improvements #148

Closed lsetiawan closed 7 years ago

lsetiawan commented 7 years ago
miguelcleon commented 7 years ago

When I run docker-compose up I get:


ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong Compose file version. Either specify a version of "2" (or "2.0") and place your service definitions under the `services` key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/

I haven't used docker compose before, FYI.

lsetiawan commented 7 years ago

@miguelcleon Looks like you have an older version of docker compose. Go ahead and try changing version: to '2', rather than 3.

miguelcleon commented 7 years ago

that is strange I literally just installed it. I checked my version of docker-engine and it says it is up to date. I tried changing to version: to '2'

now I get:

ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
lsetiawan commented 7 years ago

@miguelcleon Are you running in linux box?

lsetiawan commented 7 years ago

https://github.com/docker/compose/issues/1214

miguelcleon commented 7 years ago

yes ubuntu 16.04

lsetiawan commented 7 years ago

@miguelcleon Try using sudo docker-compose up?

miguelcleon commented 7 years ago

yes, I needed to use sudo, so we should add that to the readme. Now I'm getting another error though:

Creating dockerdeploy_db_1
Creating dockerdeploy_app_1
Attaching to dockerdeploy_db_1, dockerdeploy_app_1
db_1   | FATAL:  could not open directory "pg_tblspc": No such file or directory
dockerdeploy_db_1 exited with code 1
lsetiawan commented 7 years ago

Darn. It didn't include blank folders. Go ahead and create pg_tblspc under dbdata.

lsetiawan commented 7 years ago

I'll see how I can fix this. Maybe I'll just have a script that does the DB deployment rather than already built db.

lsetiawan commented 7 years ago

@miguelcleon Included the empty folders. See if that works now.

miguelcleon commented 7 years ago

Well I got another error:


app_1  | psql: could not connect to server: Connection refused
app_1  |    Is the server running on host "db" (172.18.0.2) and accepting
app_1  |    TCP/IP connections on port 5432?
app_1  | Postgres is unavailable - sleeping
app_1  | psql: could not connect to server: Connection refused
app_1  |    Is the server running on host "db" (172.18.0.2) and accepting
app_1  |    TCP/IP connections on port 5432?
app_1  | Postgres is unavailable - sleeping
app_1  |                                     List of databases
app_1  |        Name       |  Owner   | Encoding |  Collate   |   Ctype    |   Access privileges   
app_1  | ------------------+----------+----------+------------+------------+-----------------------
app_1  |  postgres         | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
app_1  |  template0        | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
app_1  |                   |          |          |            |            | postgres=CTc/postgres
app_1  |  template1        | postgres | UTF8     | en_US.utf8 | en_US.utf8 | =c/postgres          +
app_1  |                   |          |          |            |            | postgres=CTc/postgres
app_1  |  template_postgis | postgres | UTF8     | en_US.utf8 | en_US.utf8 | 
app_1  | (4 rows)
app_1  | 
app_1  | Postgres is up - executing command
app_1  | Activating environment...
app_1  | Migrate django tables
app_1  | Traceback (most recent call last):
app_1  |   File "/ODM2-Admin/manage.py", line 10, in <module>
app_1  |     execute_from_command_line(sys.argv)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
app_1  |     utility.execute()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
app_1  |     self.fetch_command(subcommand).run_from_argv(self.argv)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
app_1  |     self.execute(*args, **cmd_options)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
app_1  |     output = self.handle(*args, **options)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 81, in handle
app_1  |     connection.prepare_database()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 25, in prepare_database
app_1  |     with self.cursor() as cursor:
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 254, in cursor
app_1  |     return self._cursor()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 229, in _cursor
app_1  |     self.ensure_connection()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
app_1  |     self.connect()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
app_1  |     six.reraise(dj_exc_type, dj_exc_value, traceback)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
app_1  |     self.connect()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 189, in connect
app_1  |     self.connection = self.get_new_connection(conn_params)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
app_1  |     connection = Database.connect(**conn_params)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/psycopg2/__init__.py", line 130, in connect
app_1  |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
app_1  | django.db.utils.OperationalError: FATAL:  database "odm2" does not exist
app_1  | 
app_1  | Running server...
app_1  | Unhandled exception in thread started by <function wrapper at 0x7ff3375ce5f0>
app_1  | Traceback (most recent call last):
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
app_1  | Performing system checks...
app_1  | 
app_1  | System check identified no issues (0 silenced).
app_1  |     fn(*args, **kwargs)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 128, in inner_run
app_1  |     self.check_migrations()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/core/management/base.py", line 422, in check_migrations
app_1  |     executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/migrations/executor.py", line 20, in __init__
app_1  |     self.loader = MigrationLoader(self.connection)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 52, in __init__
app_1  |     self.build_graph()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 209, in build_graph
app_1  |     self.applied_migrations = recorder.applied_migrations()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
app_1  |     self.ensure_schema()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
app_1  |     if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 254, in cursor
app_1  |     return self._cursor()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 229, in _cursor
app_1  |     self.ensure_connection()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
app_1  |     self.connect()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/utils.py", line 94, in __exit__
app_1  |     six.reraise(dj_exc_type, dj_exc_value, traceback)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
app_1  |     self.connect()
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 189, in connect
app_1  |     self.connection = self.get_new_connection(conn_params)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/django/db/backends/postgresql/base.py", line 176, in get_new_connection
app_1  |     connection = Database.connect(**conn_params)
app_1  |   File "/opt/conda/envs/odm2adminenv/lib/python2.7/site-packages/psycopg2/__init__.py", line 130, in connect
app_1  |     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
app_1  | django.db.utils.OperationalError: FATAL:  database "odm2" does not exist
app_1  | 
lsetiawan commented 7 years ago

Aha. Alright. I'll just create a script that builds the database. Thanks for testing it.

miguelcleon commented 7 years ago

No problem, I'm heading home, talk to you tomorrow.

lsetiawan commented 7 years ago

@miguelcleon hopefully that works. Let me know. Thanks.

lsetiawan commented 7 years ago

ping @emiliom

lsetiawan commented 7 years ago

@miguelcleon Have you tried this yet? I think now it might break due to the recent release with redis..

lsetiawan commented 7 years ago

ping @miguelcleon I've updated the docker part of things.

miguelcleon commented 7 years ago

@lsetiawan yes it works! one change is needed for the readme. The docker container to attach to for creating a superuser is now named odm2adminapp instead of odm2admintest

lsetiawan commented 7 years ago

@miguelcleon i haven't updated the readme yet.

miguelcleon commented 7 years ago

Actually maybe it would be odm2admintest I used docker compose as I believe dockerhub doesn't contain these changes. I think we just have to test it after merging this. Sound good @lsetiawan ?

lsetiawan commented 7 years ago

I think we just have to test it after merging this.

Sounds good to me. Thanks!

miguelcleon commented 7 years ago

Ok, I've merged this. I created two additional PRs of my own and merged them also. I've then created a new release https://github.com/miguelcleon/ODM2-Admin/releases/tag/v0.1006-beta