-
Notifications
You must be signed in to change notification settings - Fork 1
Development Environment Setup
- Clone the repository
$ git clone https://github.com/Velle-log/hs-api
-
Copy env variable defaults to
.env& update.env
$ cp .env.default .env -
Install docker following these instructions for Ubuntu. Windows & Mac users install Docker Desktop.
-
Ubuntu users will have to install docker-compose tool separately.
-
Create & Run Docker Containers
$ docker-compose up -d
Use command $ docker-compose up --build -d, in case you make changes to the Dockerfile.
- Running Commands Inside API Container
$ docker exec -it api <any command>
Alternatively, you can run $ docker exec -it api /bin/bash to get shell access to run any number of commands in the container.
It's a good practice to run docker exec -it api <any command> to run commands inside the container.
Furthermore, make sure that your manage.py is executable.
If it isn't, change permissions:
$ docker exec -it api chmod u+x manage.py.
Read more about chmod here
-
Initialize Database
docker exec -it api pipenv run ./manage.py migrate
docker exec -it api pipenv run ./manage.py createsuperuser -
Setup OAuth2 Application
- Add Application
- Update
client_typefield topublic& leave other fields as they are and hit Save.
Virtual environment is managed by pipenv inside the container.
Inside the container, use $ pipenv run xyz abc to run commands under the virtual environment.
Alternatively, you can just open a new shell with virtual-environment created by running $ pipenv shell and then running $ xyz abc and other commands.
It's a good practice to use $ pipenv run xyz abc to run commands for the same reason we use sudo in linux instead of just logging in as root and executing commands. On the other hand it gives you enough time to contemplate over how bad your life has gone that you have to work on this project.