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

Commit

Permalink
fix: Update the Docker Image
Browse files Browse the repository at this point in the history
  • Loading branch information
husainattar committed Jul 24, 2020
1 parent b5b6de9 commit 23fa252
Show file tree
Hide file tree
Showing 91 changed files with 1,971 additions and 3,309 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This action uses commitlint to lint commit messages and check for the required guidelines
# as given by the config file commitlint.config.js

name: Check Commit Messages

on:
pull_request:
branches: [ develop ]

jobs:
check-commits:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0
- uses: actions/[email protected]
- run: yarn add @commitlint/{config-conventional,cli}
- run: yarn run commitlint --from HEAD~${{ github.event.pull_request.commits }} --to HEAD
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ install:
- pip install coveralls==0.4.4
- sudo apt-get install python-gdal
before_script:
- export GOOGLE_MAPS_API_KEY=$GOOGLE_MAPS_API_KEY
- export SECRET_KEY=foobarbaz
# - curl -o ipdb.tar.gz https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENSE_KEY&suffix=tar.gz
# - tar -xzf ipdb.tar.gz -C systers_portal/
- psql -c "CREATE DATABASE systersdb;" -U postgres
script:
- coverage run systers_portal/manage.py test --settings=systers_portal.settings.testing
Expand Down
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
37 changes: 37 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module.exports = {
parserPreset: 'conventional-changelog-conventionalcommits',
rules: {
'body-leading-blank': [1, 'always'],
'body-max-line-length': [2, 'always', 100],
'footer-leading-blank': [1, 'always'],
'footer-max-line-length': [2, 'always', 100],
'header-max-length': [2, 'always', 100],
'scope-case': [2, 'always', 'lower-case'],
'subject-case': [
2,
'never',
['sentence-case', 'start-case', 'pascal-case', 'upper-case']
],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test'
]
]
}
};
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
6 changes: 4 additions & 2 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django==1.11.6
Django==1.11.29
Pillow==4.3.0
django-allauth==0.33.0
django-braces==1.11.0
Expand All @@ -7,6 +7,8 @@ django-ckeditor==5.3.1
django-crispy-forms==1.7.0
django-guardian==1.4.9
django-imagekit==4.0.1
djangocms-admin-style==1.2.7
psycopg2==2.7.3.2
python3-openid==3.1.0
geoip2==3.0.0
django-ipware==3.0.0

1 change: 1 addition & 0 deletions systers_portal/GeoLite2-City_20200616/COPYRIGHT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Database and Contents Copyright (c) 2020 MaxMind, Inc.
Binary file not shown.
3 changes: 3 additions & 0 deletions systers_portal/GeoLite2-City_20200616/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Use of this MaxMind product is governed by MaxMind's GeoLite2 End User License Agreement, which can be viewed at https://www.maxmind.com/en/geolite2/eula.

This database incorporates GeoNames [https://www.geonames.org] geographical data, which is made available under the Creative Commons Attribution 4.0 License. To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/.
1 change: 1 addition & 0 deletions systers_portal/GeoLite2-City_20200616/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Latitude and longitude are not precise and should not be used to identify a particular street address or household.
31 changes: 25 additions & 6 deletions systers_portal/blog/tests/test_forms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from cities_light.models import Country, City
from django.contrib.auth.models import User
from django.test import TestCase

Expand All @@ -12,8 +13,11 @@ class AddNewsFormTestCase(TestCase):
def setUp(self):
self.user = User.objects.create_user(username='foo', password='foobar')
self.systers_user = SystersUser.objects.get(user=self.user)
country = Country.objects.create(name='Bar', continent='AS')
location = City.objects.create(name='Foo', display_name='Foo',
country=country)
self.community = Community.objects.create(name="Foo", slug="foo",
order=1,
order=1, location=location,
admin=self.systers_user)

def test_add_news_form(self):
Expand Down Expand Up @@ -41,8 +45,11 @@ class EditNewsFormTestCase(TestCase):
def setUp(self):
self.user = User.objects.create_user(username='foo', password='foobar')
self.systers_user = SystersUser.objects.get(user=self.user)
country = Country.objects.create(name='Bar', continent='AS')
location = City.objects.create(name='Foo', display_name='Foo',
country=country)
self.community = Community.objects.create(name="Foo", slug="foo",
order=1,
order=1, location=location,
admin=self.systers_user)

def test_edit_news_form(self):
Expand Down Expand Up @@ -73,8 +80,11 @@ class AddResourceFormTestCase(TestCase):
def setUp(self):
self.user = User.objects.create_user(username='foo', password='foobar')
self.systers_user = SystersUser.objects.get(user=self.user)
country = Country.objects.create(name='Bar', continent='AS')
location = City.objects.create(name='Foo', display_name='Foo',
country=country)
self.community = Community.objects.create(name="Foo", slug="foo",
order=1,
order=1, location=location,
admin=self.systers_user)

def test_add_resource_form(self):
Expand Down Expand Up @@ -102,8 +112,11 @@ class EditResourceFormTestCase(TestCase):
def setUp(self):
self.user = User.objects.create_user(username='foo', password='foobar')
self.systers_user = SystersUser.objects.get(user=self.user)
country = Country.objects.create(name='Bar', continent='AS')
location = City.objects.create(name='Foo', display_name='Foo',
country=country)
self.community = Community.objects.create(name="Foo", slug="foo",
order=1,
order=1, location=location,
admin=self.systers_user)

def test_edit_news_form(self):
Expand Down Expand Up @@ -134,8 +147,11 @@ class TagFormTestCase(TestCase):
def setUp(self):
self.user = User.objects.create_user(username='foo', password='foobar')
self.systers_user = SystersUser.objects.get(user=self.user)
country = Country.objects.create(name='Bar', continent='AS')
location = City.objects.create(name='Foo', display_name='Foo',
country=country)
self.community = Community.objects.create(name="Foo", slug="foo",
order=1,
order=1, location=location,
admin=self.systers_user)

def test_tag_form(self):
Expand All @@ -160,8 +176,11 @@ class ResourceTypeFormTestCase(TestCase):
def setUp(self):
self.user = User.objects.create_user(username='foo', password='foobar')
self.systers_user = SystersUser.objects.get(user=self.user)
country = Country.objects.create(name='Bar', continent='AS')
location = City.objects.create(name='Foo', display_name='Foo',
country=country)
self.community = Community.objects.create(name="Foo", slug="foo",
order=1,
order=1, location=location,
admin=self.systers_user)

def test_resourceType_form(self):
Expand Down
6 changes: 5 additions & 1 deletion systers_portal/blog/tests/test_mixins.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from cities_light.models import Country, City
from django.contrib.auth.models import User
from django.test import TestCase, RequestFactory
from django.views.generic import TemplateView
Expand All @@ -13,8 +14,11 @@ def setUp(self):
self.factory = RequestFactory()
self.user = User.objects.create_user(username='foo', password='foobar')
self.systers_user = SystersUser.objects.get(user=self.user)
country = Country.objects.create(name='Bar', continent='AS')
location = City.objects.create(name='Foo', display_name='Foo',
country=country)
self.community = Community.objects.create(name="Foo", slug="foo",
order=1,
order=1, location=location,
admin=self.systers_user)

def test_get_context_data_empty(self):
Expand Down
11 changes: 9 additions & 2 deletions systers_portal/blog/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from cities_light.models import Country, City
from django.test import TestCase
from django.contrib.auth.models import User

Expand All @@ -24,8 +25,11 @@ class NewsModelTestCase(TestCase):
def setUp(self):
self.user = User.objects.create(username='foo', password='foobar')
self.systers_user = SystersUser.objects.get(user=self.user)
country = Country.objects.create(name='Bar', continent='AS')
location = City.objects.create(name='Foo', display_name='Foo',
country=country)
self.community = Community.objects.create(name="Foo", slug="foo",
order=1,
order=1, location=location,
admin=self.systers_user)

def test_str(self):
Expand All @@ -41,8 +45,11 @@ class ResourceModelTestCase(TestCase):
def setUp(self):
self.user = User.objects.create(username='foo', password='foobar')
self.systers_user = SystersUser.objects.get(user=self.user)
country = Country.objects.create(name='Bar', continent='AS')
location = City.objects.create(name='Foo', display_name='Foo',
country=country)
self.community = Community.objects.create(name="Foo", slug="foo",
order=1,
order=1, location=location,
admin=self.systers_user)

def test_unicode(self):
Expand Down
Loading

0 comments on commit 23fa252

Please sign in to comment.