Welcome to the Department for Business and Trade's Selling Online Overseas service.
This respository was originally named navigator
, and within the repository the main django app and local database are still named navigator
.
Locally install:
- Python 3
- Postgres 9 postgres
- Node 6 node
- Java 8 runtime java
- Virtualenv VirtualEnv
- A database management app. On Mac a good option is postgresapp
...And create a new Virtual Environment using $ virtualenv ENV
in the project root folder.
Add the following environment variables to your local environment.
DATABASE_URL=postgres://localhost/navigator
DJANGO_SETTINGS_MODULE=navigator.settings.dev
SECRET_KEY=REPLACE_ME_WITH_AN_ACTUAL_SECRET_KEY
STORAGE_TYPE=local
One approach is to add these to the ENV/bin/activate
script. You will need to add environment variable setting at the bottom of the file and unsetting in the deactivate function.
deactivate () {
...
# Unset environment variables
unset DATABASE_URL
unset DJANGO_SETTINGS_MODULE
unset SECRET_KEY
unset STORAGE_TYPE
}
...
# Set environment variables
export DATABASE_URL=postgres://localhost/navigator
export DJANGO_SETTINGS_MODULE=navigator.settings.dev
export SECRET_KEY=lasdadslkdaslk
export STORAGE_TYPE=local
Activate the virtual environment using $ source env/bin/activate
. You will each time you start a new terminal window.
Start your local database management app.
Scripts to manage the project are inside the make file in the root folder.
Run $ make build_local
to run the "build_local" script. If this raises any errors, you can debug by running the individual commands within this script which are listing or referenced in the make file.
Run $ make run_local
to run the local server. This will be available at localhost:8008
The test script runs a pep8 style check, django tests and a coverage report.
$ make test
You are now in a position to contribute to the repository.
To make the sso features work locally add the following to your machine's /etc/hosts
:
IP Adress | URL |
---|---|
127.0.0.1 | buyer.trade.great |
127.0.0.1 | supplier.trade.great |
127.0.0.1 | sso.trade.great |
127.0.0.1 | api.trade.great |
127.0.0.1 | profile.trade.great |
127.0.0.1 | exred.trade.great |
Then log into directory-sso
via sso.trade.great:8001
, and use navigator
on soo.trade.great:8008
On local machine, SSO is turned off by default.
If you need to enable, set the FEATURE_ENFORCE_STAFF_SSO_ENABLED
to true
.
You also need to set:
STAFF_SSO_AUTHBROKER_URL
AUTHBROKER_CLIENT_ID
AUTHBROKER_CLIENT_SECRET
Speak to webops or a team mate for the above values.
If you need to rebuild the project, wiping the database, run:
$ make rebuild
These older instructions are kept here for reference as of 20 Feb 2019.
It either locally using virtual environments, or within Docker containers
Languages/applications needed
- Python 3
- Docker & Docker Compose docker (optional)
- Postgres 9 postgres (required if NOT using docker)
- Node 6 node (required if NOT using docker)
- Java 8 runtime java (required if NOT using docker)
Create a local file to instruct make
that you want to use docker:
echo "
NAV_BUILD_TYPE=docker
"> build.env
Create a local .env
file with the development and testing ports you want to use:
echo "
DEV_PORT=8000
TEST_PORT=9000
"> .env
Create a local file to store your any custom environment variables, for starters, the Django settings module for the dev container to use:
echo "
DJANGO_SETTINGS_MODULE=navigator.settings.dev
"> vars.env
Set up the containers, build the project, and run the server:
make
Create a local file to instruct make that you want to use local building:
echo "
NAV_BUILD_TYPE=local
"> build.env
Create a local file to store your desired environment variables:
echo "
DATABASE_URL=postgres://localhost/navigator
DJANGO_SETTINGS_MODULE=navigator.settings.dev
SECRET_KEY=REPLACE_ME_WITH_AN_ACTUAL_SECRET_KEY
STORAGE_TYPE=local
"> scripts/local/vars.env
To install virtualenv, run
[sudo] pip install virtualenv virtualenvwrapper
Make a virtual environment for this app:
mkvirtualenv -p /usr/local/bin/python3 navigator
Install dependencies, set up the database, and run the project:
make
To just run the project, execute the following (activating the virtual environment with workon
is not necessary if using docker):
workon navigator # Only required if running in virtualenv, not docker
make run
Then visit localhost:8008
https://github.com/uktrade?q=directory https://github.com/uktrade?q=great