This repository is meant to help get an etools development environment up and running. It is not used for any production setup.
The repo is basically a collection of submodules, each of which represents a different docker service that is part of etools.
To start using this please get familiar with git submodules if you haven't used them before: - https://git-scm.com/book/en/v2/Git-Tools-Submodules - https://github.com/blog/2104-working-with-submodules
- Python 2.7
- Virtualenv
- Virtualenvwrapper
- Docker
- docker-compose (version 1.14 or higher)
- Make sure you have dependencies installed
- Clone the repo:
git clone [email protected]:unicef/etools-infra.git
- Setup a virtualenv:
mkvirtualenv --no-site-packages etools
- Install fabric:
pip install fabric
- Initialize submodules and build front-end javascript:
fab init
- Contact the Dev Lead to get your db dump, name it
db1.bz2
and add it to:./db/
- Run:
fab devup
in the parent folder and wait for it. This should restore the database to the db container.- Note: you will likely see some error messages from the DB saying "ERROR: could not open extension control file" or similar.
This is okay. Just wait for the process to finish and exit, then
CTRL-C
and runfab devup
again.
- Note: you will likely see some error messages from the DB saying "ERROR: could not open extension control file" or similar.
This is okay. Just wait for the process to finish and exit, then
- To bring migrations up to speed
fab backend_migrations
- Subsequent starts can be run with
fab devup:quick
- Localhost server should be running on 8082
- To SSH into a web container
fab ssh:backend
(to runmanage.py createsuperuser
or other commands) - The database container should be accesible on the host machine on port 51322. The port can be changed by passing it as a parameter to the
fab devup
commands.
fab ssh:backend
cd EquiTrack
# create super user
python manage.py createsuperuser
# run schema migrations
python manage.py migrate_schemas --noinput --schema=public
# open python shell and reduce the number of countries
python manage.py shell
from EquiTrack.util_scripts import *
local_country_keep()
quit()
# run migrations scripts
python manage.py migrate_schemas --noinput
# import currencies data
python manage.py import_exchange_rates
Finally, login to localhost:8082/admin/login to finalize setting up your user:
- In the
auth.User
model make sure to set available countries - In the
users.UserProfile
model, make sure to select a country and/or a country override
You should now be able to access frontend apps.
Getting the latest changes should be a two-step process:
fab update
fab devup:quick
fab update
will pull in the latest submodule changes and update all front-end dependencies, which can be slow
and is not always necessary.
You can also run fab update:quick
which will only pull code changes and not update the front-end dependencies.
- Enable Hyper-V (PowerShell opened with Administrator rights:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
) - Install Docker for Windows, stable channel: https://docs.docker.com/docker-for-windows/install/#download-docker-for-windows
- Open Docker Settings and add your shared partitions (the one that contains the folder you are gonna install etools)
- Install Python 2.7.13 and update your system environment
Path
variable by addingC:\Python27
andC:\Python27\Scripts
- Open GitBash/CMD/PowerShell and run
pip install fabric
- Do
Dev Setup
steps to install the project
See Docker Cheatsheet for some quick tips for working with docker.
See Local Backend Setup for instructions on running the backend not in a docker container, which can be faster/easier to manage.
Coming soon...