Prerequisites are installing docker and docker-compose.
- Run
$ docker-compose up
- Open a browser at localhost:8000 and see the Django admin site
- Make code changes
- Rerun
$ docker-compose up
- Voila your change has been added.
When you are making changes to the data model, you have to generate the migration files
- Run
docker-compose up
- Then run, in another terminal window,
docker-compose exec backend python3 src/manage.py makemigrations
- Resolve anything Django asks you to resolve (non-nullable fields and such)
- Migration file should not be generated in the correct domain!
- Build the docker image again
docker build -t veritus/backend:latest .
- Rerun and your changes should be live
docker-compose up
Sometimes you need to take some actions during the migrate
command (you will see it in the console when running docker-compose).
Then simply run
docker-compose up
and then in another terminal window run
docker-compose exec backend python3 src/manage.py migrate
To run tests manually then simply run
docker-compose up
and then in another terminal window run
docker-compose exec backend python3 src/manage.py test
To run tests manually then simply run
docker-compose up
and then in another terminal window run
docker-compose exec backend pylint src/**
docker-compose up
and then in another terminal window run
docker-compose exec backend autopep8 --in-place --recursive .
The docker image here is NOT supposed to be run alone. As the backend requires a database, there is no use running it alone. Use docker-compose to run the backend and database together.
Builds a local image of the project with the tag latest
.
docker build -t veritus/backend:latest .
This is automatically done by Docker Cloud in the build process and saved in the Docker image repository online.
docker login
Input credentials.
You normally dont have to do this manually as the build process takes care of it.
docker push <IMAGE-NAME>:</TAG>
Example:
docker push veritus/backend:latest
Docker compose can be used here to start the backend with a database. Simply run
$ docker-compose up
It also works to use this during development, as docker-compose mounts the source code directory into the docker container when run. Meaning you simply need to rerun
docker-compose up
after making code changes.
Run this to get the id of the docker container
$ docker ps
Then run this command to get the IP address of the container (should be close to the bottom)
$ docker inspect <id>
Then open pgAdmin
- Click "Add a connection to a server" (claw at top)
- Insert IP address you found out
- Find the username and password in the docker-compose.yml file
- Voila!
docker-compose exec backend python3 src/manage.py runcrons