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

Fix docker compose deployment. #220

Closed lsetiawan closed 5 years ago

lsetiawan commented 5 years ago

Overview

This PR fix the docker-compose ODM2Admin deployment. Should work now, though some icons missing on the app itself, not sure why :unamused:

lsetiawan commented 5 years ago

Pinging @emiliom in case you want to learn :smile:

miguelcleon commented 5 years ago

building on dockerhub now.

lsetiawan commented 5 years ago

@miguelcleon Did everything work?

lsetiawan commented 5 years ago

Ooops, sorry Emilio, accident button push :sweat_smile:

miguelcleon commented 5 years ago

@lsetiawan so I'm getting a database error, see previous comment for more.

odm2admindb | ERROR:  schema "admin" already exists
odm2admindb | STATEMENT:  CREATE SCHEMA admin;

Maybe the schema drop statement is not working then this line fails https://github.com/miguelcleon/ODM2-Admin/blob/f7b2bb5e37cbf64cf9f7a105f6f2e1c1114849ae/docker/odm2admin/odm2database/odm2adminDB.sql#L32

looks like there is a typo somewhere using 'datname' instead of databasename?

lsetiawan commented 5 years ago

@lsetiawan so I'm getting a database error, see previous comment for more.

I ran into that before, that's why I added the drop schema.

lsetiawan commented 5 years ago

And 'datname' is correct. See https://www.postgresql.org/docs/9.6/catalog-pg-database.html

lsetiawan commented 5 years ago

What OS are you using?

lsetiawan commented 5 years ago

I'm getting this error now :disappointed:. Did you change something?

odm2adminapp | Migrate django tables
odm2adminapp | Traceback (most recent call last):
odm2adminapp |   File "manage.py", line 10, in <module>
odm2adminapp |     execute_from_command_line(sys.argv)
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
odm2adminapp |     utility.execute()
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
odm2adminapp |     django.setup()
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
odm2adminapp |     apps.populate(settings.INSTALLED_APPS)
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
odm2adminapp |     app_config.import_models()
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
odm2adminapp |     self.models_module = import_module(models_module_name)
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/importlib/__init__.py", line 126, in import_module
odm2adminapp |     return _bootstrap._gcd_import(name[level:], package, level)
odm2adminapp |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
odm2adminapp |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
odm2adminapp |   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
odm2adminapp |   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
odm2adminapp |   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
odm2adminapp |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
odm2adminapp |   File "/ODM2-Admin/odm2admin/models.py", line 166, in <module>
odm2adminapp |     class Actions(models.Model):
odm2adminapp |   File "/ODM2-Admin/odm2admin/models.py", line 178, in Actions
odm2adminapp |     verbose_name='begin date time clock off set (from GMT)', default=settings.UTC_OFFSET)
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/conf/__init__.py", line 58, in __getattr__
odm2adminapp |     val = getattr(self._wrapped, name)
odm2adminapp | AttributeError: 'Settings' object has no attribute 'UTC_OFFSET'
miguelcleon commented 5 years ago

I did change the branch in the docker file, it should actually be -b fix_docker I suppose. https://github.com/ODM2/ODM2-Admin/commit/608d748d2639e06d890ae1313e7efeef481e5a08

miguelcleon commented 5 years ago

I'm using debian

lsetiawan commented 5 years ago

I'm getting this error now disappointed. Did you change something?

Seems like the settings for docker and the main settings files have really diverged. This is why I'm seeing the error.

lsetiawan commented 5 years ago

More work needs to be done to use settings from main code rather than the copy, so it doesn't get out of sync.

miguelcleon commented 5 years ago

yup the docker settings are not up to date

miguelcleon commented 5 years ago

@lsetiawan ok, I updated the settings.

miguelcleon commented 5 years ago

oh you were saying to copy the settings from the main code. That would be more DRY and better.

miguelcleon commented 5 years ago

now I'm getting:

ERROR: for 80810e9d00b7_odm2adminapp  Cannot create container for service app: invalid volume specification: '2f315ce6f7b9a79fdcd874b97e43dffc58d768dfa3336c61155c91c6a396a7a0:templatesAndSettings/settings:rw': invalid mount config for type "volume": invalid mount path: 'templatesAndSettings/settings' mount path must be absolute

ERROR: for app  Cannot create container for service app: invalid volume specification: '2f315ce6f7b9a79fdcd874b97e43dffc58d768dfa3336c61155c91c6a396a7a0:templatesAndSettings/settings:rw': invalid mount config for type "volume": invalid mount path: 'templatesAndSettings/settings' mount path must be absolute
miguelcleon commented 5 years ago

looks like the database started though.

lsetiawan commented 5 years ago

now I'm getting:

ERROR: for 80810e9d00b7_odm2adminapp  Cannot create container for service app: invalid volume specification: '2f315ce6f7b9a79fdcd874b97e43dffc58d768dfa3336c61155c91c6a396a7a0:templatesAndSettings/settings:rw': invalid mount config for type "volume": invalid mount path: 'templatesAndSettings/settings' mount path must be absolute

ERROR: for app  Cannot create container for service app: invalid volume specification: '2f315ce6f7b9a79fdcd874b97e43dffc58d768dfa3336c61155c91c6a396a7a0:templatesAndSettings/settings:rw': invalid mount config for type "volume": invalid mount path: 'templatesAndSettings/settings' mount path must be absolute

It's almost like you're not using the current docker compose yml... :/

Found it: https://github.com/ODM2/ODM2-Admin/pull/220/files#diff-fbfa49647fbd69b5fb80b317d90ffa07R28

Probably just delete that line.

miguelcleon commented 5 years ago

huh, ok I tried these steps to redo the docker-compose https://github.com/docker/compose/issues/2127

looks like maybe I'm missing a package.


odm2adminapp | Migrate django tables
odm2adminapp | Traceback (most recent call last):
odm2adminapp |   File "manage.py", line 10, in <module>
odm2adminapp |     execute_from_command_line(sys.argv)
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
odm2adminapp |     utility.execute()
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
odm2adminapp |     django.setup()
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
odm2adminapp |     apps.populate(settings.INSTALLED_APPS)
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
odm2adminapp |     app_config = AppConfig.create(entry)
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
odm2adminapp |     module = import_module(entry)
odm2adminapp |   File "/opt/conda/envs/odm2adminenv/lib/python3.6/importlib/__init__.py", line 126, in import_module
odm2adminapp |     return _bootstrap._gcd_import(name[level:], package, level)
odm2adminapp |   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
odm2adminapp |   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
odm2adminapp |   File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
odm2adminapp | ModuleNotFoundError: No module named 'djutils'
miguelcleon commented 5 years ago

yup, djutils was commented out of requirements.txt, I couldn't say why I did that.

miguelcleon commented 5 years ago

Oh, maybe because it killed travis

lsetiawan commented 5 years ago

huh, ok I tried these steps to redo the docker-compose docker/compose#2127

For reference, you could just do this before doing up: docker-compose -f docker/docker-deploy/docker-compose.yml down --volumes

lsetiawan commented 5 years ago

djutils is not in conda-forge channel, so uncommenting it breaks the install step.

miguelcleon commented 5 years ago

oh yup I was just going to say that


conda create --yes -n odm2adminenv -c conda-forge python=3.6 libgdal boost pytz gdal --file requirements.txt
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - djutils

Current channels:

  - https://conda.anaconda.org/conda-forge/linux-64
  - https://conda.anaconda.org/conda-forge/noarch
  - https://repo.anaconda.com/pkgs/main/linux-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/free/linux-64
  - https://repo.anaconda.com/pkgs/free/noarch
  - https://repo.anaconda.com/pkgs/r/linux-64
  - https://repo.anaconda.com/pkgs/r/noarch
  - https://repo.anaconda.com/pkgs/pro/linux-64
  - https://repo.anaconda.com/pkgs/pro/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.
miguelcleon commented 5 years ago

looking promising... loading CVs. Travis lives.

lsetiawan commented 5 years ago

Well?

miguelcleon commented 5 years ago

Yes! It works 🍾 👍 😃

miguelcleon commented 5 years ago

Working... I had to setup an ssh tunnel, which I never do, so it took me a minute. image

miguelcleon commented 5 years ago

Thanks a ton @lsetiawan !