Skip to content

Add Makefile with Docker and Django development commands #157

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

Open
wants to merge 1 commit into
base: main
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
70 changes: 70 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Lithium Django Project Makefile
# Helper commands for development workflow

.PHONY: build up down restart logs shell django-shell test migrate makemigrations collectstatic createsuperuser help

# Default target
.DEFAULT_GOAL := help

# Variables
DOCKER_COMPOSE = docker-compose
DOCKER_EXEC = $(DOCKER_COMPOSE) exec web
MANAGE_PY = python manage.py

# Docker commands
build:
$(DOCKER_COMPOSE) build

up:
$(DOCKER_COMPOSE) up

up-d:
$(DOCKER_COMPOSE) up -d

down:
$(DOCKER_COMPOSE) down

restart:
$(DOCKER_COMPOSE) restart

logs:
$(DOCKER_COMPOSE) logs -f

# Django commands
shell:
$(DOCKER_EXEC) bash

django-shell:
$(DOCKER_EXEC) $(MANAGE_PY) shell

test:
$(DOCKER_EXEC) $(MANAGE_PY) test

migrate:
$(DOCKER_EXEC) $(MANAGE_PY) migrate

makemigrations:
$(DOCKER_EXEC) $(MANAGE_PY) makemigrations

collectstatic:
$(DOCKER_EXEC) $(MANAGE_PY) collectstatic --noinput

createsuperuser:
$(DOCKER_EXEC) $(MANAGE_PY) createsuperuser

# Help command
help:
@echo "Available commands:"
@echo " build - Build Docker images"
@echo " up - Start containers in foreground"
@echo " up-d - Start containers in background"
@echo " down - Stop and remove containers"
@echo " restart - Restart containers"
@echo " logs - View container logs"
@echo " shell - Open a bash shell in the web container"
@echo " django-shell - Open Django shell in the web container"
@echo " test - Run Django tests"
@echo " migrate - Apply database migrations"
@echo " makemigrations - Create new database migrations"
@echo " collectstatic - Collect static files"
@echo " createsuperuser - Create a Django superuser"