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

Commit

Permalink
fix: Update docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
husainattar authored and SanketDG committed Jul 28, 2020
1 parent 25231b7 commit 17fd770
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 25 deletions.
26 changes: 24 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
FROM python:2.7
# getting the base Image
FROM python:3.6

MAINTAINER Ana Balica <[email protected]>

# Updated by
LABEL HUSSAIN="[email protected]"

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
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
15 changes: 10 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
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
volumes:
- .:/usr/src/portal
- .:/usr/src/portal
ports:
- "8000:8000"
- "8000:8000"
links:
- db
- db
environment:
- DJANGO_SETTINGS_MODULE=systers_portal.settings.docker

- 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 @@ -10,4 +10,4 @@ django-imagekit==4.0.2
psycopg2==2.8.5
python3-openid==3.2.0
geoip2==4.0.1
django-ipware==3.0.0
django-ipware==3.0.0
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

0 comments on commit 17fd770

Please sign in to comment.