I found a Django project and failed to get it running in Docker container in the following way:
git clone git clone https://github.com/NAL-i5K/django-blast.git
$ cat requirements.txt
in this files the below dependencies had to be updated:- psycopg2==2.8.6
I have the following Dockerfile:
FROM python:2
ENV PYTHONUNBUFFERED=1
RUN apt-get update && apt-get install -y postgresql-client
WORKDIR /code
COPY requirements.txt /code/
RUN pip install -r requirements.txt
COPY . /code/
RUN mkdir -p /var/log/django
RUN mkdir -p /var/log/i5k
For docker-compose.yml
I use:
version: "3"
services:
db:
image: postgres
volumes:
- ./data/db:/var/lib/postgresql/data
- ./scripts/install-extensions.sql:/docker-entrypoint-initdb.d/install-extensions.sql
environment:
- POSTGRES_DB=postgres
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
links:
- db
$ cat scripts/install-extensions.sql
CREATE EXTENSION hstore;
I had to change:
$ vim i5k/settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': 'db',
'PORT': '5432',
}
}
Next, I ran docker-compose up --build
and opened in Browser http://localhost:8000/admin/
which caused:
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.8.12
Python Version: 2.7.18
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.postgres',
'axes',
'rest_framework',
'rest_framework_swagger',
'pipeline',
'app',
'blast',
'migrate_account',
'suit',
'filebrowser',
'django.contrib.admin',
'django.contrib.admindocs',
'social.apps.django_app.default',
'captcha',
'dashboard',
'proxy',
'hmmer',
'clustal',
'webapollo_sso',
'drupal_sso')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'axes.middleware.FailedLoginMiddleware',
'app.middleware.SocialAuthExceptionMiddleware')
Traceback:
File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in wrapper
254. return self.admin_view(view, cacheable)(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
110. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
222. if not self.has_permission(request):
File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in has_permission
162. return request.user.is_active and request.user.is_staff
File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py" in inner
225. self._setup()
File "/usr/local/lib/python2.7/site-packages/django/utils/functional.py" in _setup
376. self._wrapped = self._setupfunc()
File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/middleware.py" in <lambda>
22. request.user = SimpleLazyObject(lambda: get_user(request))
File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/middleware.py" in get_user
10. request._cached_user = auth.get_user(request)
File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in get_user
167. user_id = _get_user_session_key(request)
File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in _get_user_session_key
59. return get_user_model()._meta.pk.to_python(request.session[SESSION_KEY])
File "/usr/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in __getitem__
48. return self._session[key]
File "/usr/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in _get_session
181. self._session_cache = self.load()
File "/usr/local/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in load
21. expire_date__gt=timezone.now()
File "/usr/local/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
127. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py" in get
328. num = len(clone)
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py" in __len__
144. self._fetch_all()
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
965. self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py" in iterator
238. results = compiler.execute_sql()
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
840. cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
79. return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/site-packages/django/db/utils.py" in __exit__
98. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at /admin/
Exception Value: relation "django_session" does not exist
LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se...
What did I miss?
Thank you in advance