Discussion:
[Mayan EDMS: 2135] Docker using environment variables
Phiroz
2017-09-27 09:57:11 UTC
Permalink
hi,

first off i would like to thank anyone for any help.

i'm still new to docker, so i'm learning this as i go.

i'm using the Docker version 17.06.2-ce, build cec0b72
mayanedms image : 2.7.3.
host is ubuntu 16.04

i'm trying connect to the mysql DB running on the host,
so i'm using these options

i have an a file with the environment variables

inside mayan_edms_env
MAYAN_DATABASE_DRIVER=django.db.backends.mysql
MAYAN_DATABASE_NAME=mayan_edms
MAYAN_DATABASE_USER=mayan
MAYAN_DATABASE_PASSWORD=12345
MAYAN_DATABASE_HOST=localhost

--env-file=/home/user/mayan_edms_env (to pass in the environment variables)
-v /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock (to map the
mysql socket in host to container)

full command:

docker run -d --name mayan-edms --env-file=/home/user/mayan_edms_env
--restart=always -p 8000:80 -v mayan_media:/var/lib/mayan -v
/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock
mayanedms/mayanedms:2.7.3

unfortunately when i run the above

docker ps
it keeps showing status restarting.

when i tried this it has no issues.
docker run -d ---env-file=/home/user/mayan_edms_env -v
/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock
mayanedms/mayanedms:2.7.3 ( this command was able to connect to the sql, as
it created the tables in the database)
docker run -d --name mayan-edms --restart=always -p 8000:80 -v
mayan_media:/var/lib/mayan mayanedms/mayanedms:2.7.3

i'm hoping someone can point me where i messed up.
thanks for any help/hints/things to check.
--
---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mayan-edms+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Phiroz
2017-09-27 10:52:23 UTC
Permalink
here's an update.
i clear off all containers and all volumes. dropped the existing database
and created a new blank one.
i ran the command without the detach option.


mayan.settings <7> [INFO] "<module>() No local.py settings file. Using
defaults."
mayan.settings <16> [INFO] "<module>() Good local.py found. Using user
settings."
Existing settings file at:
/usr/local/lib/python2.7/dist-packages/mayan/settings/local.py. Backup,
remove this file, and try again.
Operations to perform:
Apply all migrations: acls, actstream, admin, auth, authtoken, autoadmin,
cabinets, checkouts, common, contenttypes, converter, django_gpg, djcelery,
document_comments, document_indexing, document_parsing,
document_signatures, document_states, documents, dynamic_search, events,
linking, lock_manager, mailer, mayan_statistics, metadata, motd, ocr,
permissions, sessions, sites, sources, tags
Running migrations:
Applying contenttypes.0001_initial... OK
Applying permissions.0001_initial... OK
Applying auth.0001_initial... OK
Applying permissions.0002_auto_20150628_0533... OK
Applying acls.0001_initial... OK
Applying acls.0002_auto_20150703_0513... OK
Applying actstream.0001_initial...Traceback (most recent call last):
File "/usr/local/bin/mayan-edms.py", line 10, in <module>
execute_from_command_line(sys.argv)
File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 367, in execute_from_command_line
utility.execute()
File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
line 294, in run_from_argv
self.execute(*args, **cmd_options)
File
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
line 345, in execute
output = self.handle(*args, **options)
File
"/usr/local/lib/python2.7/dist-packages/mayan/apps/common/management/commands/initialsetup.py",
line 13, in handle
pre_initial_setup.send(sender=self)
File
"/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py",
line 191, in send
response = receiver(signal=self, sender=sender, **named)
File
"/usr/local/lib/python2.7/dist-packages/mayan/apps/common/handlers.py",
line 10, in handler_pre_initial_setup
management.call_command('migrate', interactive=False)
File
"/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
line 130, in call_command
return command.execute(*args, **defaults)
File
"/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
line 345, in execute
output = self.handle(*args, **options)
File
"/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py",
line 204, in handle
fake_initial=fake_initial,
File
"/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py",
line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake,
fake_initial=fake_initial)
File
"/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py",
line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake,
fake_initial=fake_initial)
File
"/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py",
line 244, in apply_migration
state = migration.apply(state, schema_editor)
File
"/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py",
line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state,
project_state)
File
"/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/models.py",
line 532, in database_forwards
getattr(new_model._meta, self.option_name, set()),
File
"/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py",
line 333, in alter_unique_together
self.execute(self._create_unique_sql(model, columns))
File
"/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py",
line 112, in execute
cursor.execute(sql, params)
File
"/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line
64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line
94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File
"/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line
64, in execute
return self.cursor.execute(sql, params)
File
"/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py",
line 110, in execute
return self.cursor.execute(query, args)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line
205, in execute
self.errorhandler(self, exc, value)
File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py",
line 36, in defaulterrorhandler
raise errorclass, errorvalue
django.db.utils.OperationalError: (1071, 'Specified key was too long; max
key length is 767 bytes')

this location is inside the container (it does not exist in the host)
"/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py"
it fails trying to exec 'actstream.0001_initial'
--
---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mayan-edms+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Phiroz
2017-09-28 12:03:01 UTC
Permalink
here's an update.

the issue was the conversion between sqlite and mysql.
dajango has issue converting it.

so here's what i did to resolve it.

1. cleared off any old containers and volume in docker.

2. we need to create an account first, so i ran this.
docker run -d --name mayan-edms --restart=always -p 8000:80 -v
mayan_data:/var/lib/mayan mayanedms/mayanedms:2.7.3

3. used the web browser login and reset the admin password.

4. stop the container
docker stop mayan-edms

5. i'll need to copy out the sqlite database. you path may be different
sudo cp /var/lib/docker/volume/mayan_data/_data/db.sqlite3 .

6. get the sql queries .
sqlite3 db.sqlite3 .dump > db.sql

7. this will create a text file with the sql queries.

8. i used a text parser to fix some of the differences between sqlite and
mysql. i've attached it so if you want to use it you can.
sqlitetomysql db.sql > stillneedtofix.sql

9. this creates another file, which has be some what fixed.

10. choose your fav text editor and do find and replace of " to `

11. this is the tedious part, i used phpmyadmin to import the sql into the
db,
so at each error search for the table name in the example below is
metadata_metadatatype
and add the ` for each of the column names. so it'll look something like
this.

CREATE TABLE IF NOT EXISTS metadata_metadatatype (`id` integer NOT NULL
PRIMARY KEY AUTO_INCREMENT, `name` varchar(48) NOT NULL UNIQUE, `label`
varchar(48) NOT NULL, `default` varchar(128) NULL, `lookup` text NULL,
`validation` varchar(64) NOT NULL, `parser` varchar(64) NOT NULL);

there are quite a few of these, so just go down the line.

12. once you've gone through the queries, drop and create the database and
import it in again. you may have missed something or something did not get
imported.

13, now you'll need to clear off the container and volume
docker rm -v mayan-edms

14.
docker run -d --name mayan-edms --env-file=mayan_edms_env --restart=always
-p 8000:80 -v mayan_media:/var/lib/mayan -v
/var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock
mayanedms/mayanedms:2.7.3

--name mayan-edms : container name
--env-file=mayan_edms_env : the enviroment file
-v /var/run/mysqld/mysqld.sock:/var/run/mysqld/mysqld.sock : map the mysql
socket to the container

15. go to the web browser, remember at the start why i said to reset the
password, the onetime login doesn't run.
insert in a document and ocr it, the contents will now appear in the mysql
server instead of the sqlite.

well i hope this helps someone.
--
---
You received this message because you are subscribed to the Google Groups "Mayan EDMS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mayan-edms+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...