- 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 up
If 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 up
vagrant ssh
cd /usr/local/apps/marineplanner-core/
source env/bin/activate
cd marineplanner
python manage.py runserver 0.0.0.0:8000
Then go here
This assumes you have built an app to be deployed on mp-core
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git
mkdir /usr/local/apps
sudo chgrp adm /usr/local/apps
cd /usr/local/apps
git clone https://github.com/Ecotrust/marineplanner-core.git
cd /usr/local/apps/marineplanner-core/scripts/
sudo chmod +x vagrant_provision0.sh
sudo ./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/apps
git 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 ssh
into 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/marineplanner
python manage.py startapp appname
replace appname with your new app's name
- Make app installable
- inside the directory
/apps/YOUR_NEW_APP/
create the following files:README.md
LICENSE
setup.py
MANIFEST.in
.gitignore
- update
gitignore
with 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/scripts
run the following but replaceappname
with 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.py
with normal django administrative tasks , use the keyworddj
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
orvagrant provision
will cause the provisioning script to re-run. Adding the flag--no-provision
tovagrant 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 changelisten_addresses
:
sudo nano /etc/postgresql/9.3/main/postgresql.conf
listen_addresses = '*'
-
Enter into
pg_hba.conf
and add thehost
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:
- 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/master
origin/master
pertains 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 collectstatic
to 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 compress
to 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 clone
for exisiting module or create a new direcotry and usegit init
to 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.txt
and 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.py
and 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 clone
your 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.txt
file 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 install
and 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