Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

docs: Updated the Docker setup for portal #610

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
FROM python:2.7
# getting the base Image
FROM python:3.6-slim-buster

MAINTAINER Ana Balica <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better we have an official Email ID here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes so I can remove my email.


EXPOSE 8000

# Initializing the working directory
WORKDIR /usr/src

RUN mkdir portal

RUN cd portal

# Re-Initializing the working directory
WORKDIR /usr/src/portal

# Copy the requirement.txt for installing
COPY requirements/prod.txt /usr/src/portal/requirements/prod.txt
RUN pip install -r requirements/prod.txt
COPY requirements/dev.txt /usr/src/portal/requirements/dev.txt

# Installing the requirements
RUN pip install -r requirements/dev.txt

# Installing the GDAL Library
# RUN apt-get install python-gdal
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:ubuntugis/ppa
RUN apt-get install -y gdal-bin python-gdal python3-gdal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need python-gdal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes because while building it gives me an error regarding gdal lib not found during executing the cities_light command. So I tried to include and it resolved error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes because while building it gives me an error regarding gdal lib not found during executing the cities_light command. So I tried to include and it resolved error.

are you sure about "python-gdal" as image using here is python3.6 , then why we need "python-gdal" library of python 2 .
As, gdal lib not found during executing the cities_light command can be fixed by only installing "python3-gdal".

Also , installing "python-gdal" here will also install python2 and other dependency in the image .

So, My suggestion is to only use "python3-gdal" here and verify for issue and also sure image size will further reduce.

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,30 @@ production at the moment. It may be configured to do so in the future.
1. **This step will require the Django SECRET_KEY.**
Run `docker run -e SECRET_KEY=foobarbaz portal_web`.
1. Run `docker-compose run web python systers_portal/manage.py migrate`.

* After above command now Run `docker-compose run web python systers_portal/manage.py makemigrations`
for complete migration and then re-run `docker-compose run web python systers_portal/manage.py migrate`.
* Note: If you face any error like **Docker cannot link or db not running**
then run the following command in another terminal `docker-compose up db`
and again run the above following command

1. Run `docker-compose run web python systers_portal/manage.py cities_light` for downloading and importing data for django-cities-light.
1. *Optional:*
Run `docker-compose run web python systers_portal/manage.py createsuperuser`
if you wish to create a superuser to access the admin panel.

For working with database open up new terminal and run `docker-compose run db bash`
and then run `psql -U postgres -d postgres -h db` to enter in postgres db.
Run `\dt` for checking tables and `\q` for exiting the postgres terminal
and stop the container's bash using CTRL+D.
1. Navigate to `systers_portal/systers_portal/settings/base.py` file and change to `ALLOWED_HOST=['O.O.O.O']`
so that we can access the docker-container from any ip address.
1. Run `docker-compose up` to start the webserver for the Django Systers Portal
project.
* Note If you face any error like **portal_web cannot start service web** then run
following command `service docker restart` then again run the above following command
1. Systers Portal should be running on port 8000.
* If you are on Linux, enter `http://0.0.0.0:8000` in your browser.
* If you are using boot2docker on Windows or Mac OS X, enter
Expand Down
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
db:
image: postgres:9.4
ports:
- "5432:5432"
environment:
- POSTGRES_HOST_AUTH_METHOD=trust

web:
build: .
command: python systers_portal/manage.py runserver 0.0.0.0:8000
Expand All @@ -10,5 +15,5 @@ web:
links:
- db
environment:
- SECRET_KEY=foobarbaz
- DJANGO_SETTINGS_MODULE=systers_portal.settings.docker

2 changes: 1 addition & 1 deletion requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ django-apscheduler==0.4.1
git+https://github.com/Chive/django-multiupload.git#egg=django-multiupload
geoip2==4.0.2
nltk==3.5
gensim==3.8.3
gensim==3.8.3
8 changes: 0 additions & 8 deletions systers_portal/community/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,44 +83,38 @@ def get_absolute_url(self):

def has_changed_name(self):
"""Check if community has a new name
:return: True if community changed name, False otherwise
"""
return self.name != self.original_name

def has_changed_admin(self):
"""Check if community has a new admin
:return: True if community changed admin, False otherwise
"""
return self.admin != self.original_admin

def add_member(self, systers_user):
"""Add community member
:param systers_user: SystersUser objects
"""
self.members.add(systers_user)

def remove_member(self, systers_user):
"""Remove community member
:param systers_user: SystersUser object
:return:
"""
self.members.remove(systers_user)

def get_fields(self):
"""Get model fields of a Community object
:return: list of tuples (fieldname, fieldvalue)
"""
return [(field.name, getattr(self, field.name)) for field in
Community._meta.fields]

def set_new_admin(self, new_admin):
"""Transfer the admin role from the old to the new admin
:param new_admin: SystersUser object new admin of the community
:return: OK if setting was successful, NOT_MEMBER if settings was
unsuccessful, since the new admin is not a member of the
Expand Down Expand Up @@ -210,15 +204,13 @@ def __str__(self):

def get_fields(self):
"""Get model fields of a RequestCommunity object
:return: list of tuples (fieldname, fieldvalue)
"""
return [(field.name, getattr(self, field.name)) for field in
RequestCommunity._meta.fields]

def get_verbose_fields(self):
"""Get verbose names of RequestCommunity object's model fields
:return: list of tuples (verbosefieldname, fieldvalue)
"""

Expand Down
12 changes: 3 additions & 9 deletions systers_portal/community/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,9 @@ class CommunityLandingView(RedirectView):

def get_redirect_url(self, *args, **kwargs):
"""Provide a redirect url based on the following conditions:

* if a Community has no pages, redirect to the news list views
* if a Community has at least one page, redirect to the page with the
lowest order (aka first page)
"""
lowest order (aka first page)"""
community = get_object_or_404(Community, slug=kwargs['slug'])
community_pages = CommunityPage.objects.filter(
community=community).order_by('order')
Expand Down Expand Up @@ -293,17 +291,13 @@ def get_context_data(self, **kwargs):
def get_community(self):
"""Overrides the method from CommunityMenuMixin to extract the current
community.

:return: Community object
"""
:return: Community object"""
return self.object

def get_page_slug(self):
"""Overrides the method from CommunityMenuMixin to extract the current
page slug or the lack of it.

:return: string CommunityPage slug
"""
:return: string CommunityPage slug"""
return self.kwargs['page_slug']


Expand Down