53 lines
1.1 KiB
Makefile
53 lines
1.1 KiB
Makefile
# Variables
|
|
DOCKER_COMPOSE = docker-compose
|
|
PROJECT_NAME = django-docker
|
|
|
|
# Commands
|
|
.PHONY: services start stop restart migrate createsuperuser logs clean
|
|
|
|
# Start all Docker services
|
|
services:
|
|
@$(DOCKER_COMPOSE) up --build -d
|
|
@echo "Docker services started."
|
|
|
|
# Stop all Docker services
|
|
stop:
|
|
@$(DOCKER_COMPOSE) down
|
|
@echo "Docker services stopped."
|
|
|
|
# Restart all Docker services
|
|
restart: stop services
|
|
@echo "Docker services restarted."
|
|
|
|
# Migrate the database
|
|
migrate:
|
|
@$(DOCKER_COMPOSE) exec web python manage.py migrate
|
|
@echo "Database migrations applied."
|
|
|
|
# Create a superuser for Django
|
|
createsuperuser:
|
|
@$(DOCKER_COMPOSE) exec web python manage.py createsuperuser
|
|
|
|
# View logs from all services
|
|
logs:
|
|
@$(DOCKER_COMPOSE) logs -f
|
|
|
|
# Clean up Docker resources
|
|
clean:
|
|
@$(DOCKER_COMPOSE) down -v --remove-orphans
|
|
@echo "Docker environment cleaned."
|
|
|
|
# Run the Django development server
|
|
runserver:
|
|
@$(DOCKER_COMPOSE) exec web python manage.py runserver 0.0.0.0:8000
|
|
|
|
# Shell into the Django container
|
|
shell:
|
|
@$(DOCKER_COMPOSE) exec web sh
|
|
|
|
# Run tests
|
|
test:
|
|
@$(DOCKER_COMPOSE) exec web python manage.py test
|
|
@echo "Tests completed."
|
|
|