Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orchestrate infra #69

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
147 changes: 140 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,152 @@
venv
.idea
*.pyc
*~
__pycache__
*.*~
vagrant-fabric-lxc
django_project/media/images
visual_changelog.db
.vagrant

node_modules
id_dsa.pub
id_rsa.pub
docs/build
fabgis_resources
private.py
.coverage
sample_config.yaml
fabfile.py
.sass-cache
npm-debug.log
.idea
django_blog_it
node_modules/
django_dev.log
logs/
celerybeat-schedule
celerybeat.pid
client_secret.json
# client_secret.json
*.egg-info/
<<<<<<< HEAD
sonlinux marked this conversation as resolved.
Show resolved Hide resolved


# Vim leftovers
*.*~

# project specifc
deployment/.env
xmlrunner

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
opensource_job_portal.egg-info/
docs/build
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos
# into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/

#PyCharm
.idea

# Virtual env
venv

# Node
django_project/static
node_modules

# Working data not intended to be versioned
data_for_import
scrap.html
.pycharm_helpers
.sudo_as_admin_successful

# Pg cluster for docker
deployment/pg/
deployment/pg/postgres_data/9.3
deployment/pg/postgres_staging_data/9.3
deployment/pg/postgres_dev_data/9.3
deployment/sql/healthyrivers-old.sql
# Template for apt-cacher
# static and media dirs
deployment/logs
deployment/static
deployment/media
deployment/docker/71-apt-cacher-ng
django_project/static
django_project/core/settings/secret.py

# local media
django_project/media

# OSX Crap
.DS_Store

# Backups
*.dmp
deployment/backups

# We should never version the btsync keys
deployment/btsync-media.env
deployment/btsync-db.env
deployment/btsync-db.env.PRODUCTION
deployment/btsync-media.env.PRODUCTION
.sync/
# These don't get versioned since they are generated on the fly
deployment/pgadmin-data
deployment/rabbitmq
deployment/reports
deployment/docker/Dockerfile-prod
deployment/docker/projecta.tar.gz
celerybeat-schedule
django_project/node_modules/
optimized.js
=======
docs/build
>>>>>>> cee7d162bc5ccb91a0eb6a979415f208b65a2e0c
4 changes: 2 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
0.1
basic site functionality.
1.0
Stable functionality.
12 changes: 0 additions & 12 deletions Dockerfile

This file was deleted.

121 changes: 121 additions & 0 deletions README-dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Developer Documentation

**Note:** This documentation is intentionally generic so that it can
be copy-pasted between projects - do not put project specific details here.

## Application architecture under docker

The following diagram provides and overview of the core architecture
components (Database, uwsgi server, web server):

![dockerdjangoarchitecture - new page 1](https://cloud.githubusercontent.com/assets/178003/5024388/750b85c8-6b12-11e4-97b0-c73b2d07e539.png)


The blue box is there to provide a means to develop on the same environment
as you deploy and would not be relevant for server side deployments.
Everything is managed using docker containers, with pycharm
making ssh connections into the developer container and using the
python interpreter found therein. Newer versions of PyCharm have 'native' docker support
but after testing we opted to continue to use the ssh method described here. You may want to
test when new versions of PyCharm come out in case they have improved the direct docker support.

**Note:** You don't need to use this architecture, you can deploy as a standard
django app using virtualenv and locally installed postgis/mysql, nginx etc.

## Setup pycharm to work with a remove docker development environment

### Build and run your dev docker image

This image extends the production one, adding ssh to it. You must
have built the production one first by following the "Quick Installation Guide"!
When it's done, you can continue with this command:

Linux and MacOS:

```
make build-devweb
make devweb
```

Windows:

```
make-devbuild.bat
make-devweb.bat
```

### Create a remote interpreter in pycharm

Open the project in pycharm then do:

* File -> Settings
* Project Interpreter
* Click on the gear icon next to project interpreter
* Add remote...

Now use these credentials:

* SSH Credentials (tick)
* Host: localhost
* Port: (use the ssh port specified in the docker-compose.yml file)
* User name: root
* Auth type: password (and tick 'save password')
* Password: docker
* Python interpreter path: ``/usr/local/bin/python``

When prompted about host authenticity, click Yes.
After the python interpreter is set, set its path mapping:

* **Local path:** `<path to your git repo>/django_project`
* **Remote path:** `/home/web/django_project`

After that you should see something like this:
`<Project root>/django_project→/home/web/django_project`

In settings, django support:

* tick to enable django support.
* Set django project root to the path on your host that holds django code e.g.
``<path to code base>/django_project``
* Set the settings option to your setting profile e.g.
``jobsp.settings_server``. If you need to use custom settings, copy
this file e.g. ``jobsp.settings_local.py`` and place your modifications in your
personalised copy. The first import of your custom file should import from
jobsp.settings_server.

* manage script (leave default)


### Create the django run configuration

* Run -> Edit configurations
* Click the `+` icon in the top left corner
* Choose ``Django server`` from the popup list

Now set these options:

* **Name:** Django Server
* **Host:** 0.0.0.0
* **Port:** (use the http port specified in the docker-compose.yml file, e.g. 8080)`*` **Run browser** If checked, it will open the url after you click run. You should be able to access the running projecta on 0.0.0.0:61202 (the port that mapped to 8080)
* **Additional options:** ``--settings=jobsp.settings_server``
* **Run browser:** Optionally set this to your IP address (MacOS/Linux) or your specific IP address (Windows) followed by the port forward address for port 8080 specified in your ``docker-compose.yml`` file. For example: ``http://0.0.0.0:65202``.
* **Environment vars:** Leave as default unless you need to add something to the env
* **Python interpreter:** Ensure it is set you your remote interpreter (should be
set to that by default)
* **Interpreter options:** Leave blank
* **Path mappings:** Here you need to indicate path equivalency between your host
filesystem and the filesystem in the remote (docker) host. Click the ellipsis
and add a run that points to your git checkout on your local host and the
/home/web directory in the docker host. e.g.
* **Local path:** <path to your git repo>/django_project
* **Remote path:** /home/web/django_project
* click OK to save your run configuration

Now you can run the server using the green triangle next to the Django server
label in the run configurations pull down. Debug will also work and you will be
able to step through views etc as you work.


## Running Tests

sonlinux write stuff here....
Loading