-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
56 lines (46 loc) · 1.56 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Makefile for managing the PostgreSQL Docker setup with docker-compose
# Load environment variables from .env
include .env
export $(shell sed 's/=.*//' .env)
# Default target
.PHONY: build up down logs ps publish
# Build the Docker image and run the containers
build:
@echo "Building and starting containers..."
docker-compose up --build -d
# Start the containers without rebuilding
up:
@echo "Starting containers..."
docker-compose up -d
# Stop and remove the containers
down:
@echo "Stopping and removing containers..."
docker-compose down
# View logs from containers
logs:
@echo "Viewing logs..."
docker-compose logs -f
# Show running containers
ps:
@echo "Showing running containers..."
docker-compose ps
# Clean up unused Docker resources (optional)
clean:
@echo "Cleaning up unused Docker resources..."
docker system prune -f
# Tag and push the Docker image to DockerHub
publish:
@echo "Tagging the image..."
docker tag $(IMAGE_NAME):$(TAG) $(DOCKER_USERNAME)/$(IMAGE_NAME):$(TAG)
@echo "Pushing the image to Docker Hub..."
docker push $(DOCKER_USERNAME)/$(IMAGE_NAME):$(TAG)
# Display help
help:
@echo "Available commands:"
@echo " build Build the Docker image and run MongoDB containers"
@echo " up Start MongoDB containers without rebuilding"
@echo " down Stop and remove MongoDB containers"
@echo " logs View logs from running MongoDB containers"
@echo " ps Show running MongoDB containers"
@echo " clean Clean up unused Docker resources"
@echo " publish Tag and push the Docker image to Docker Hub"