To start project, run:
docker-compose upThe API will then be available at http://127.0.0.1:8000
production is at api.farmz2u.com
Run unit tests:
docker-compose run --rm app sh -c "python manage.py wait_for_db && python manage.py test"Run linting:
docker-compose run --rm app sh -c "flake8"Run tests and linting together:
docker-compose run --rm app sh -c "python manage.py wait_for_db && python manage.py test && flake8"Add a new user to aws-vault:
aws-vault add <user>Initialise aws-vault in current terminal on macOS/Linux:
aws-vault exec <USER> --duration=12hInitialise aws-vault in current command prompt window on Windows:
aws-vault exec <USER> --duration=12h -- cmd.exeBuild docker image in current directory:
docker build -t <tag> .Starting services:
docker-compose upRebuilding services:
docker-compose up --buildStarting services with specific config file:
docker-compose -f <file-path> upIn order to pull the application image, authentication with ECR is required.
To authenticate with ECR:
$(aws ecr get-login --no-include-email --region us-east-1)Replace the following variables:
<DB_HOST>: The hostname for the database (retrieve from Terraform apply output)<DB_PASS>: The password for the database instance (retrieve from GitLab CI/CD variables)
docker run -it \
-e DB_HOST=<DB_HOST> \
-e DB_NAME=bloodbase \
-e DB_USER=bloodbaseappuser \
-e DB_PASS=<DB_PASS> \
<ECR_REPO>:latest \
sh -c "python manage.py wait_for_db && python manage.py createsuperuser"Check Makefile for short cuts
Initialise the Terraform state file locally, and download and Terraform providers.
docker-compose -f deploy/docker-compose.yml terraform initRun Terraform auto format command on code.
docker-compose -f deploy/docker-compose.yml run --rm terraform fmtRun Terraform validation on code.
docker-compose -f deploy/docker-compose.yml run --rm terraform validateTerraform allows you to create, remove or select a workspace using the CLI.
List all workspaces:
docker-compose -f deploy/docker-compose.yml terraform workspace listIn the below commands, replace
<name>with the name of the workspace.
Create:
docker-compose -f deploy/docker-compose.yml terraform workspace new <name>Select:
docker-compose -f deploy/docker-compose.yml terraform workspace select <name>Delete:
docker-compose -f deploy/docker-compose.yml terraform workspace delete <name>Output a plan for changes Terraform will make to AWS resources.
docker-compose -f deploy/docker-compose.yml terraform planRun Terraform apply to make changes described in plan to actual resources (this can create, remove or change resources)
docker-compose -f deploy/docker-compose.yml terraform applyRemove any resources managed by Terraform (tear down all infrastructure) for selected workspace
docker-compose -f deploy/docker-compose.yml terraform destroy