Run all commands in the stack
directory (cd stack
from the root directory).
-
Install Docker and Docker Compose
On Mac and Windows, the easiest way is to install Docker Desktop
Or you can install Docker and Docker Compose directly.
-
Copy the
compose/.env.template
file tocompose/.env
. Replace theSECRET_KEY
value with your Django key, and replace theONET_PASSWORD
with the O*NET account password (ping the jobhopper channel if you don't know the password). -
Build the Docker images by running
./dev build
. You will need to run this whenever the dependencies for the frontend or api change. -
Start the app by running
./dev up
.You can start a shell in the Django container with
./dev shell api
, and a shell in the database container with./dev shell db
.You can start
psql
, an interactive PostgreSQL shell, with./dev psql
. -
To run backend tests, once the container is running, this command will work in a new command window to execute the tests against the running API container:
./compose/dev-deployment exec api python manage.py test
-
Install Python 3.7.
-
Install virtualenv from
pip
:python3.7 -m pip install virtualenv OR on Windows python -m pip install virtualenv
-
Clone this repo to local:
git clone https://github.com/codeforboston/jobhopper.git
-
Create a virtual environment of Python 3.7 in the root of the local repo:
cd jobhopper python3.7 -m virtualenv --python=3.7 venv OR on Windows cd jobhopper python -m virtualenv --python=3.7 venv
-
Activate venv:
. ./venv/bin/activate OR on Windows ./venv/Scripts/activate
-
Install project dependencies from
requirements.txt
:pip install -r requirements.txt
-
Create a personal
.env
file to include environment variables for the app: (Note: Don't include.env
in commit, thus it's in.gitignore
):SECRET_KEY='[generated key]'
You can get your own 50 character secret key from here.
-
Create PostgreSQL DB:
a. Install PostgreSQL 12
b. Start PostgreSQL service and check if clusters are running.
sudo service postgresql start pg_lsclusters
If the text is green, it's working.
c. Run
psql
through the newly createdpostgres
user.sudo -i -u postgres psql
d. Create a new user/role for the site to access the database to. Name it however you like as long as you note the username and password for putting it in
.env
.CREATE ROLE [user] SUPERUSER LOGIN PASSWORD '[password]';
e. Create a new database for the site to access. Name it however you like (preferably 'jobhopperdatabase') as long as you note the name of the database for putting it in
.env
.CREATE DATABASE [database name] WITH OWNER = [user];
f. Exit out of
psql
andpostgres
user with theexit
command for both cases.g. Add those information you written into the
.env
file.SECRET_KEY='[generated key]' DB_NAME='[database name]' DB_USER='[user/role name]' DB_PASSWORD='[password]' DB_HOST='127.0.0.1' # Localhost IP
-
Migrate from
manage.py
in root.python manage.py migrate
-
Now run the server via this script:
python manage.py runserver
-
Go to the URL
[baseurl]/jobs/api/leads/
and test out creating entries. -
Go to the URL
[baseurl]/api/v1/health
and ensure it returns JSON data. -
Go to the URL
[baseurl]/jobs
and ensure it returns data.