postgres service for external use
This commit is contained in:
75
Makefile
Normal file
75
Makefile
Normal file
@@ -0,0 +1,75 @@
|
||||
# Makefile for PostgreSQL Service
|
||||
|
||||
.PHONY: setup start stop restart status logs backup restore monitor clean help
|
||||
|
||||
# Default environment
|
||||
ENV ?= dev
|
||||
|
||||
help:
|
||||
@echo "PostgreSQL Service Management"
|
||||
@echo "============================"
|
||||
@echo "Available commands:"
|
||||
@echo " make setup - Setup the PostgreSQL service (make scripts executable)"
|
||||
@echo " make start - Start the PostgreSQL service"
|
||||
@echo " make stop - Stop the PostgreSQL service"
|
||||
@echo " make restart - Restart the PostgreSQL service"
|
||||
@echo " make status - Check the status of the PostgreSQL service"
|
||||
@echo " make logs - View the logs of the PostgreSQL service"
|
||||
@echo " make backup - Create a backup of the PostgreSQL database"
|
||||
@echo " make restore - Restore a backup of the PostgreSQL database"
|
||||
@echo " make monitor - Monitor the PostgreSQL service"
|
||||
@echo " make clean - Remove all containers, volumes, and networks"
|
||||
@echo ""
|
||||
@echo "Environment options:"
|
||||
@echo " make start ENV=dev - Start with development configuration (default)"
|
||||
@echo " make start ENV=staging - Start with staging configuration"
|
||||
@echo " make start ENV=production - Start with production configuration"
|
||||
|
||||
setup:
|
||||
@echo "Setting up PostgreSQL service..."
|
||||
@cd scripts && ./setup.sh
|
||||
|
||||
start:
|
||||
@echo "Starting PostgreSQL service with $(ENV) environment..."
|
||||
ifeq ($(ENV), dev)
|
||||
@docker-compose up -d
|
||||
else
|
||||
@docker-compose -f docker-compose.yaml -f environments/$(ENV).yaml up -d
|
||||
endif
|
||||
@echo "PostgreSQL service started."
|
||||
|
||||
stop:
|
||||
@echo "Stopping PostgreSQL service..."
|
||||
ifeq ($(ENV), dev)
|
||||
@docker-compose down
|
||||
else
|
||||
@docker-compose -f docker-compose.yaml -f environments/$(ENV).yaml down
|
||||
endif
|
||||
@echo "PostgreSQL service stopped."
|
||||
|
||||
restart: stop start
|
||||
|
||||
status:
|
||||
@echo "PostgreSQL service status:"
|
||||
@docker-compose ps
|
||||
|
||||
logs:
|
||||
@echo "PostgreSQL service logs:"
|
||||
@docker-compose logs -f postgres
|
||||
|
||||
backup:
|
||||
@echo "Creating PostgreSQL backup..."
|
||||
@cd scripts && ./backup.sh
|
||||
|
||||
restore:
|
||||
@echo "Restoring PostgreSQL backup..."
|
||||
@cd scripts && ./restore.sh $(BACKUP)
|
||||
|
||||
monitor:
|
||||
@echo "Monitoring PostgreSQL service..."
|
||||
@cd scripts && ./monitor.sh
|
||||
|
||||
clean:
|
||||
@echo "Cleaning up PostgreSQL service..."
|
||||
@docker-compose down -v --remove-orphans
|
||||
@echo "PostgreSQL service cleaned up."
|
||||
Reference in New Issue
Block a user