The following is the recommended folder structure for the entire MARCO project and the customized provisioning script is inherently dependent on it. Altering the folder and naming structure will require modifications to the provisioning script, so please be aware! The provisioning script is designed to be a one-step install after initial setup.
-- marco-portal2
-- apps (all remaining repositories within MidAtlanticPortal)
-- mardona-analysistools
-- madrona-features
-- etc.
To quickly clone all the repositiories from MidAtlanticPortal, run one of the following curl commands with Ruby/Perl. In doing so, this will clone all of the respositories at the same level
curl -s https://api.github.com/orgs/MidAtlanticPortal/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["clone_url"]} ]}'
PERL:
curl -s https://api.github.com/orgs/MidAtlanticPortal/repos\?per_page\=200 | perl -ne 'print "$1\n" if (/"clone_url": "([^"]+)/)' | xargs -n 1 git clone
Putting this all together, your process will look something like this (using Perl on Linux for this example):
cd [working directory]
curl -s https://api.github.com/orgs/MidAtlanticPortal/repos\?per_page\=200 | perl -ne 'print "$1\n" if (/"clone_url": "([^"]+)/)' | xargs -n 1 git clone
mkdir ./marco-portal2/apps
shopt -s extglob
mv !(*marco-portal2*) ./marco-portal2/apps/
shopt -u extglob
Once your folder structure is set up, create a config.ini
file by making a copy of the config.ini.template
located at marco-portal2/marco
and modify the following
Create a /static/
directory at the root level and move the /bower_components/
directory (also found at the root level) within it
Create a /media/
directory at the root level and retrieve the live server's media folder via ssh/sftp located at /webapps/marco_portal_media/
and add it to the /media/
path. Refer to your team's technical documentation for server login (username and password) credentials
data_manager
folder within the media directory - unless you're interested in several GBs of utfgrid layers.
mkdir media
scp -r user@live_server:~/webapps/marco_portal_media/documents ./media/ #11s -- RDH 7/27/2017
scp -r user@live_server:~/webapps/marco_portal_media/group_images ./media/ #11s
scp -r user@live_server:~/webapps/marco_portal_media/images ./media/ #3m19s
scp -r user@live_server:~/webapps/marco_portal_media/original_images ./media/ #3m57s
scp user@live_server:~/webapps/marco_portal_media/index.html ./media/ #12s
Retrieve the data & content fixture from ~/fixtures/dev_fixture.json
via ssh/sftp and place it at the root level of marco-portal2
cd [working dir]/marco-portal2
scp user@live_server:~/fixtures/dev_fixture.json ./ #25s
Download and install vagrant and virtual box (if you haven't already done so already)
At the root of marco-portal2
, run vagrant up
and let it install ALL of dependencies MARCO relies upon
At this point, you should be completely setup!
You probably want to create a superuser once you're in your VM, so that you have access to both the Django and Wagtail backend
Access your VM by running vagrant ssh
. This will automatically log you into your virtual machine with your virtual environment activated at the project root level.
Shortcuts
To use /manage.py
with normal django administrative tasks , use the keyword dj
dj makemigrations
dj migrate
dj createsuperuser
dj dumpdata
etc.
Typing djrun
will run your dev server - remember to add your sample data first (see #5):
NOTE: The provisioning script is designed for a fresh install and will completely wipe the database and any associated content - IF you decide to shutdown your VM! Outside of halting your vagrant machine, running vagrant up
or vagrant provision
will cause the provisioning script to re-run. Adding the flag --no-provision
to vagrant up
will ignore the script.
If you decide to use pgAdmin3 for database management rather than using the command line, you'll need to allow/enable access to your virtual machine.
Enter into postgres.conf
and change listen_addresses
:
sudo nano /etc/postgresql/9.3/main/postgresql.conf
listen_addresses = '*'
Enter into pg_hba.conf
and add the host
line:
sudo nano /etc/postgresql/9.3/main/pg_hba.conf
host all all 10.0.0.0/16 md5
Restart postgresql
sudo /etc/init.d/postgresql restart
Within pgAdmin3, modify your settings:
Since this project is modularized, changes to a submodule only requires server updates to that specific submodule - rather than the entire code base.
source ~/env/marco_portal2/bin/activate
cd /home/midatlantic/env/marco_portal2/src/[THE-NAME-OF-YOUR-SUBMODULE]
cd ~/webapps/marco_portal/marco/src/
git fetch && git reset -q --hard origin/master
origin/master
pertains to the main master branch - you can change that to whatever your branch you'd likeorigin/prototype
cd ~/webapps/marco_portal/marco
python manage.py collectstatic
to collect all the neccessary static (js/css) files
python manage.py collectstatic -i utfgrid
python manage.py compress
to compress~/webapps/marco_portal/apache2/bin/restart
Adding a new module to marco requires a few additional steps for both local/development setup and deployment.
Local/Development setup:
marco-portal2/apps
git clone
for exisiting module or create a new direcotry and use git init
to set up your new repository.
marco-portal2/requirements.txt
and add the newly created git remote repository (e.g. -e git+https://github.com/MidAtlanticPortal/your_new_repo.git@master#egg=an_alias
). the @master#egg=
assigns an alias (simple name) for your modulemarco-portal2/marco/marco/settings.py
and add your new module's alias as an INSTALLED_APPS
. (e.g., INSTALLED_APPS = [ 'an_alias']
)vagrant provision
Deployment:
source ~/env/marco_portal2/bin/activate
cd /home/midatlantic/env/marco_portal2/src/
git clone
your new module repositorycd ~/code/marco_portal2/prototype/
git fetch && git reset -q --hard origin/prototype
requirements.txt
file and copy the line you added for your repo (e.g., -e git+https://github.com/MidAtlanticPortal/new_repo.git@master#egg=an_alias
)pip install
and paste (e.g.,pip install -e git+https://github.com/MidAtlanticPortal/new_repo.git@master#egg=an_alias
) and runcd ~/webapps/marco_portal/marco
python manage.py collectstatic -i utfgrid
python manage.py compress
~/webapps/marco_portal/apache2/bin/restart