- Clone marineplanner-core onto your local system
- Copy scripts/configure_project.sh.template to scripts/configure_project.sh
- make configure_project.sh executable
- run your new configure_project script (may need to open in vim and enter :set fileformat=unix)
vagrant up- wait 30 minutes (or more if you don't have the base box or have a slow connection)
If you have Vagrant installed on Mac:
git clone https://github.com/Ecotrust/marineplanner-core.git
cd marineplanner-core/scripts
cp configure_project.sh.template.mac configure_project.sh
chmod +x configure_project.sh
./configure_project.sh
vagrant upIf you have Vagrant installed on Linux:
git clone https://github.com/Ecotrust/marineplanner-core.git
cd marineplanner-core/scripts
cp configure_project.sh.template configure_project.sh
chmod +x configure_project.sh
./configure_project.sh
vagrant upvagrant ssh
cd /usr/local/apps/marineplanner-core/
source env/bin/activate
cd marineplanner
python manage.py runserver 0.0.0.0:8000Then go here
This assumes you have built an app to be deployed on mp-core
sudo apt-get updatesudo apt-get upgradesudo apt-get install gitmkdir /usr/local/appssudo chgrp adm /usr/local/appscd /usr/local/appsgit clone https://github.com/Ecotrust/marineplanner-core.git
cd /usr/local/apps/marineplanner-core/scripts/sudo chmod +x vagrant_provision0.shsudo ./vagrant_provision0.sh focal 3.8.0 12 3#Ubuntu focal, GEOS 3.8.0, PostgreSQL 12, PostGIS 3
cd /usr/local/apps/marineplanner-core/appsgit clone [your mp-core enabled app]- Kickoff configuration, either:
- run pre-written deployment script from package, or
- Build configuration from marineplanner-core/scripts/production_configure.sh.template
- TODO: NGINX, uwsgi, etc...
- Create a new repository in GitHub (or other) for the new app your are creating note: be empathetic in your name chooses: clearly state your intent
- Run the appropriate Development Installation bootstrap for your OS
- Wait for vagrant to complete
- Do one of the following:
- option a: include your new git repo's remote url in configure_project.sh
- option b: clone it into marineplanner-core/apps/
vagrant sshinto the machine- Activate your virtual environment, using either
- option a:
dj - option b:
source /usr/local/apps/marineplanner-core/env/bin/activate
- option a:
- Create your new app in the marineplanner-core project:
cd /usr/local/apps/marineplanner-core/marineplannerpython manage.py startapp appnamereplace appname with your new app's name
- Make app installable
- inside the directory
/apps/YOUR_NEW_APP/create the following files:README.mdLICENSEsetup.pyMANIFEST.in.gitignore
- update
gitignorewith the following:
landmapper.egg-info *.pyc .DS_Store .idea
- move
/marineplanner-core/marineplanner/YOUR_NEW_PROJECT/into/marineplanner-core/apps/YOUR_NEW_APP/ - edit LICENSE file with Ecotrust license
- edit setup.py, manifest, and readme as needed
- inside the directory
- check in your new files, commit, and push to the remote repository note: make sure you are on the master branch
- Run the following to close VM, remove old symlinks and reprovision:
exit
vagrant halt- cd into marineplanner-core/scripts if not there already and run:
rm ../marineplanner/marineplanner/urls.py
rm ../marineplanner/marineplanner/settings.py
rm ../Vagrantfile
rm vagrant_provision.sh- in the same directory
marineplanner-core/scriptsrun the following but replaceappnamewith your new module name:
./configure_project.sh appname- in the same dir run:
vagrant up
vagrant provision- ssh into VM, start up env, and run server:
vagrant ssh
cd /usr/local/apps/marineplanner-core/
source env/bin/activate
cd marineplanner
python manage.py runserver 0.0.0.0:8000=== Old Notes (under construction)===
- 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.pywith normal django administrative tasks , use the keyworddjdj makemigrations dj migrate dj createsuperuser dj dumpdata etc. -
Typing
djrunwill 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 uporvagrant provisionwill cause the provisioning script to re-run. Adding the flag--no-provisiontovagrant upwill 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.confand changelisten_addresses:
sudo nano /etc/postgresql/9.3/main/postgresql.conf
listen_addresses = '*'
-
Enter into
pg_hba.confand add thehostline: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:
- Name: marineplanner
- Host: localhost
- Port: 65432
- Username: vagrant
Since this project is modularized, changes to a submodule only requires server updates to that specific submodule - rather than the entire code base.
- SSH into the server
- Activate your virtual env -
source ~/env/marineplanner-core/bin/activate - Navigate to the submodule that you're updating
- Submodules are located at
cd /home/[username]/env/marineplanner-core/src/[THE-NAME-OF-YOUR-SUBMODULE]
- Submodules are located at
- Once you're at that path -
git fetch && git reset -q --hard origin/masterorigin/masterpertains to the main master branch - you can change that to whatever your branch you'd like
- Navigate to
cd ~/webapps/marineplanner/[project module] - Run
python manage.py collectstaticto collect all the neccessary static (js/css) files- you can use the -i flag to ignore utfgrids in the rare chance that those files seems to be "collecting"
python manage.py collectstatic -i utfgrid
- Run
python manage.py compressto compress - Restart the server -
~/webapps/marineplanner/apache2/bin/restart
Adding a new module to Marine Planner requires a few additional steps for both local/development setup and deployment.
Local/Development setup:
- create directory within
marineplanner-core/apps- Use
git clonefor exisiting module or create a new direcotry and usegit initto set up your new repository.- If this is a new git repository create a new remote origin repo within the Ecotrust orgainization. Next steps assume your new module is ready to use.
- Use
- open
marineplanner-core/requirements.txtand add the newly created git remote repository (e.g.-e git+https://github.com/Ecotrust/your_new_repo.git@master#egg=an_alias). the@master#egg=assigns an alias (simple name) for your module - open
marineplanner-core/[project]/[module]/settings.pyand add your new module's alias as anINSTALLED_APPS. (e.g.,INSTALLED_APPS = [ 'an_alias']) - run
vagrant provision
Deployment:
- ssh into the server (sandbox or production)
- activate your virtual env -
source ~/env/marineplanner-core/bin/activate - navigate to the submodule directory
cd /home/[username]/env/marineplanner-core/src/ git cloneyour new module repository- navigate to the marineplanner-core repo
cd ~/code/marineplanner-core/master/ - run
git fetch && git reset -q --hard origin/master - open the
requirements.txtfile and copy the line you added for your repo (e.g.,-e git+https://github.com/Ecotrust/new_repo.git@master#egg=an_alias) - enter
pip installand paste (e.g.,pip install -e git+https://github.com/Ecotrust/new_repo.git@master#egg=an_alias) and run - navigate to
cd ~/webapps/marineplanner-core/[project] - run
python manage.py collectstatic -i utfgrid - run
python manage.py compress - restart the server -
~/webapps/marineplanner-core/apache2/bin/restart