Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

use docker containers for postgres and redis #458

Open
wants to merge 3 commits into
base: hmc/development-env
Choose a base branch
from

Conversation

msarahan
Copy link

I think this inches forward a tiny bit. It sets up the config for an initial connection to the linked postgres database.

I had to move the setup.py call outside of the Dockerfile, because it needs to actually see the database server, and docker-compose hasn't set that up yet during build.

At this point, the database seems like it isn't quite configured right yet, and I don't know yet how to actually start up the app.

CC @hectcastro @themightychris

msarahan@twilightsparkle:~/DistrictBuilder$ sudo docker-compose up
Starting districtbuilder_redis_1
Starting districtbuilder_postgres_1
Recreating districtbuilder_django_1
Attaching to districtbuilder_redis_1, districtbuilder_postgres_1, districtbuilder_django_1
redis_1     | 1:C 15 Sep 02:47:23.353 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1     |                 _._                                                  
redis_1     |            _.-``__ ''-._                                             
redis_1     |       _.-``    `.  `_.  ''-._           Redis 3.2.10 (00000000/0) 64 bit
redis_1     |   .-`` .-```.  ```\/    _.,_ ''-._                                   
postgres_1  | LOG:  database system was shut down at 2017-09-15 02:46:59 UTC
redis_1     |  (    '      ,       .-`  | `,    )     Running in standalone mode
postgres_1  | LOG:  MultiXact member wraparound protections are now enabled
redis_1     |  |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
postgres_1  | LOG:  database system is ready to accept connections
redis_1     |  |    `-._   `._    /     _.-'    |     PID: 1
redis_1     |   `-._    `-._  `-./  _.-'    _.-'                                   
postgres_1  | LOG:  autovacuum launcher started
redis_1     |  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
redis_1     |  |    `-._`-._        _.-'_.-'    |           http://redis.io        
redis_1     |   `-._    `-._`-.__.-'_.-'    _.-'                                   
redis_1     |  |`-._`-._    `-.__.-'    _.-'_.-'|                                  
redis_1     |  |    `-._`-._        _.-'_.-'    |                                  
redis_1     |   `-._    `-._`-.__.-'_.-'    _.-'                                   
redis_1     |       `-._    `-.__.-'    _.-'                                       
redis_1     |           `-._        _.-'                                           
redis_1     |               `-.__.-'                                               
redis_1     | 
redis_1     | 1:M 15 Sep 02:47:23.354 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1     | 1:M 15 Sep 02:47:23.354 # Server started, Redis version 3.2.10
redis_1     | 1:M 15 Sep 02:47:23.354 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1     | 1:M 15 Sep 02:47:23.355 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
redis_1     | 1:M 15 Sep 02:47:23.355 * DB loaded from disk: 0.000 seconds
redis_1     | 1:M 15 Sep 02:47:23.355 * The server is now ready to accept connections on port 6379
django_1    | Validated config.
django_1    | Generated django settings for publicmapping.
django_1    | Generated django settings for reporting.
postgres_1  | ERROR:  function postgis_lib_version() does not exist at character 8
postgres_1  | HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
postgres_1  | STATEMENT:  SELECT postgis_lib_version()
django_1    | Traceback (most recent call last):
django_1    |   File "setup.py", line 180, in <module>
django_1    |     main()
django_1    |   File "setup.py", line 138, in main
django_1    |     management.call_command('syncdb', verbosity=options.verbosity, interactive=False)
django_1    |   File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 134, in call_command
django_1    |     klass = load_command_class(app_name, name)
django_1    |   File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
django_1    |     module = import_module('%s.management.commands.%s' % (app_name, name))
django_1    |   File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
django_1    |     __import__(name)
django_1    |   File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>
django_1    |     from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
django_1    |   File "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", line 6, in <module>
django_1    |     from django.db import models
django_1    |   File "/usr/local/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module>
django_1    |     backend = load_backend(connection.settings_dict['ENGINE'])
django_1    |   File "/usr/local/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
django_1    |     return getattr(connections[DEFAULT_DB_ALIAS], item)
django_1    |   File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 93, in __getitem__
django_1    |     conn = backend.DatabaseWrapper(db, alias)
django_1    |   File "/usr/local/lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 11, in __init__
django_1    |     self.ops = PostGISOperations(self)
django_1    |   File "/usr/local/lib/python2.7/site-packages/django/contrib/gis/db/backends/postgis/operations.py", line 108, in __init__
django_1    |     'template?' % self.connection.settings_dict['NAME']
django_1    | django.core.exceptions.ImproperlyConfigured: Cannot determine PostGIS version for database "district_builder". GeoDjango requires at least PostGIS version 1.3. Was the database created from a spatial database template?
django_1    | Usage: manage.py subcommand [options] [args]
django_1    | 
django_1    | Options:
django_1    |   -v VERBOSITY, --verbosity=VERBOSITY
django_1    |                         Verbosity level; 0=minimal output, 1=normal output,
django_1    |                         2=verbose output, 3=very verbose output
django_1    |   --settings=SETTINGS   The Python path to a settings module, e.g.
django_1    |                         "myproject.settings.main". If this isn't provided, the
django_1    |                         DJANGO_SETTINGS_MODULE environment variable will be
django_1    |                         used.
django_1    |   --pythonpath=PYTHONPATH
django_1    |                         A directory to add to the Python path, e.g.
django_1    |                         "/home/djangoprojects/myproject".
django_1    |   --traceback           Print traceback on exception
django_1    |   --version             show program's version number and exit
django_1    |   -h, --help            show this help message and exit
django_1    | 
django_1    | Type 'manage.py help <subcommand>' for help on a specific subcommand.
django_1    | 
django_1    | Available subcommands:
django_1    | 
django_1    | [auth]
django_1    |     createsuperuser
django_1    | 
django_1    | [compressor]
django_1    |     compress
django_1    |     mtime_cache
django_1    | 
django_1    | [django]
django_1    |     cleanup
django_1    |     compilemessages
django_1    |     createcachetable
django_1    |     dbshell
django_1    |     diffsettings
django_1    |     dumpdata
django_1    |     flush
django_1    |     loaddata
django_1    |     makemessages
django_1    |     reset
django_1    |     runfcgi
django_1    |     shell
django_1    |     sql
django_1    |     sqlall
django_1    |     sqlclear
django_1    |     sqlcustom
django_1    |     sqlflush
django_1    |     sqlindexes
django_1    |     sqlinitialdata
django_1    |     sqlreset
django_1    |     sqlsequencereset
django_1    |     startapp
django_1    |     startproject
django_1    |     syncdb
django_1    |     test
django_1    |     testserver
django_1    |     validate
django_1    | 
django_1    | [djcelery]
django_1    |     celery
django_1    |     celerybeat
django_1    |     celerycam
django_1    |     celeryd
django_1    |     celeryd_detach
django_1    |     celeryd_multi
django_1    |     celerymon
django_1    |     djcelerymon
django_1    | 
django_1    | [gis]
django_1    |     inspectdb
django_1    |     ogrinspect
django_1    | 
django_1    | [publicmapping]
django_1    |     changepassword
django_1    | 
django_1    | [redistricting]
django_1    |     database_i18n
django_1    |     exportplans
django_1    |     makelanguagefiles
django_1    |     numusers
django_1    |     reaggregate
django_1    |     removescoreconfig
django_1    |     setup
django_1    | 
django_1    | [staticfiles]
django_1    |     collectstatic
django_1    |     findstatic
django_1    |     runserver
districtbuilder_django_1 exited with code 0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant