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

issues using docker container #123

Closed miguelcleon closed 7 years ago

miguelcleon commented 7 years ago

@lsetiawan I'm back and trying to run the docker container. It seems to work except the django tables are not in the odm2admindb.backup database. Either a migration needs to be ran on the backup database so that the django tables exist or the migrate command for manage.py needs to be ran I think in startup.sh

I was trying to do this on my own branch but docker can't seem to find my repo, maybe because I added -b miguelworking to point to the branch in the dockerfile git clone command. I also tried to build the image from the local Dockerfile but it is failing with the below, not sure why.

Step 1/18 : FROM miniconda:latest
repository miniconda not found: does not exist or no pull access
lsetiawan commented 7 years ago

@miguelcleon Hang on tight on the Docker stuff right now. It used to work, but now it's broken, I am still trying to address the problem. Thanks.

Also, I put the wrong repo on docker hub, it should be continuumio/miniconda:latest

miguelcleon commented 7 years ago

Yes that fixed building the image for the local dockerfile. However when I try to run an instance of the image im getting ImportError: No module named pytz Maybe pytz just needs to be added to the requirements.txt file? I'm trying that now.

miguelcleon commented 7 years ago

adding pytz (pytz=2017.2) to requirements.txt didn't work not sure why, when i manually create the conda environment like below it worked.

conda create --yes -n odm2adminenv2 -c conda-forge python=2.7 --file /ODM2-Admin/requirements.txt

miguelcleon commented 7 years ago

@lsetiawan any chance you can take a look at this again soon? @emiliom ?

emiliom commented 7 years ago

Miguel: Don and I chatted about this today. He's probably already in touch with you, but he's actively working on this now. I had diverted his work away from ODM2 Admin late last week (FYI, towards WOFpy), but that was at least partly based on a misunderstanding on my part of where things were.

lsetiawan commented 7 years ago

@miguelcleon I've made a pull request, this would fix your errors, please merge. Thanks.

miguelcleon commented 7 years ago

@lsetiawan Ok I published the new pre-release for docker hub https://github.com/miguelcleon/ODM2-Admin/releases/tag/v0.1001-alpha

miguelcleon commented 7 years ago

@lsetiawan ok the latest release (v0.1003-alpha) now correctly uses a blank ODM2 database from docker, instead of the example DB which contains Luquillo data and shouldn't be used for this. One thing, you can't login without a superuser account setup and I'm not sure how to run python manage.py createsuperuser within the docker container. Your supposed to run it interactively in order to set a password, otherwise it will try to email you a link to set your password, but I don't think we should try to set up smtp to make that work. I guess a the question really is how do you modify the contents of the docker container after it is setup? Someone should be able to get to the settings file to modify that as well. Do you know how to do that? Maybe @ocefpaf knows?

lsetiawan commented 7 years ago

Ah, yes.

Once the application is in the background running, you can attach to the container by running: docker exec -it containerid /bin/bash, That will bring up a shell where you can activate the conda environment and run python manage.py migrate and python manage.py createsuperuser. I'll need to document that.

lsetiawan commented 7 years ago

The next round of improvements are to allow user to

  1. use their own settings file
  2. use uwsgi to run as production
  3. separating the database from the application

I was thinking to use the model like docker-erddap, where user attach volume within their host machine to specify where the settings files are, and we have some sort of template where we can let user to download and use... What do you think @ocefpaf ?

miguelcleon commented 7 years ago

Yes, that worked :+1: I was able to run bash in docker, activate the conda environment and create a super user. Great, thanks!

miguelcleon commented 7 years ago

@lsetiawan I went ahead and wrote it up. Maybe you could try this to make sure this works for you? https://github.com/miguelcleon/ODM2-Admin/commit/6ccd89a4406a5fd5b0ffb9f3d0876f11a8b3d83e

If that works let's close this issue and create a new one with the next round of improvements you outlined.

miguelcleon commented 7 years ago

@lsetiawan So your talking about generating a settings file from some sort of template?

lsetiawan commented 7 years ago

@miguelcleon yepp. basically zip the templatesAndSettings/settings. I'll try out the new blank db in a bit.

miguelcleon commented 7 years ago

ok, I made the readme more verbose https://github.com/miguelcleon/ODM2-Admin/commit/c3c3b4ec97b7b09b25327f7459d66604d04e1378