Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial makefile commands for running prjoect commands #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Define PROJECT_DIR variable to get the directory of the Makefile
this := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
PROJECT_DIR := $(dir $(this))

# Target to display help message
help:
@echo "Make targets:"
@echo "============="
@awk '/^[a-zA-Z_-]+:.*?## / {split($$0, N, ":.*?## "); printf "%-20s %s\n", N[1], N[2]}' $(MAKEFILE_LIST) | sort


# Define variables
COMPOSE = docker compose
API_CONTAINER = api

# Targets
build: ## Build containers if using GPU
$(COMPOSE) build

build-cpu: ## Build containers if using CPU
$(COMPOSE) -f docker-compose-cpu.yml build

up: ## Run containers if using GPU
$(COMPOSE) up

up-cpu: ## Run containers if using CPU
$(COMPOSE) -f docker-compose-cpu.yml up

down-cpu: ## Stop and remove the docker-compose containers if using CPU
$(COMPOSE) -f docker-compose-cpu.yml down

down: ## Stop and remove the docker-compose containers if using GPU
$(COMPOSE) -f docker-compose.yml down

migrations: ## Run database migration commands
bash run_migrations.sh

api-container: ## Grab API container and open Bash shell
$(COMPOSE) exec $(API_CONTAINER) bash

restart: ## Restart containers
$(COMPOSE) restart

test: # Run Django tests
$(COMPOSE) exec $(API_CONTAINER) bash -c "python manage.py test"

django-shell: ## Get a django Ipython shell inside the api container
$(COMPOSE) exec $(API_CONTAINER) bash -c "python manage.py shell"

db-shell: ## Get an interactive shell inside the db container
$(COMPOSE) exec pgsql bash

frontend: ## Get an interactive shell inside the frontend container
$(COMPOSE) exec frontend bash