-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
129 lines (106 loc) · 3.65 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# Variables
DOCKER_COMPOSE = docker-compose
APP_NAME = finelth-backend
# Colors for terminal output
GREEN = \033[0;32m
NC = \033[0m # No Color
INFO = @echo "${GREEN}[INFO]${NC}"
.PHONY: help build up down restart logs ps clean test clean-deps fix-install rebuild-modules
# Show help
help:
@echo "Available commands:"
@echo " make start - Start Docker container"
@echo " make build - Build Docker images"
@echo " make up - Start all services"
@echo " make down - Stop and remove all containers"
@echo " make restart - Restart all services"
@echo " make logs - View logs from all services"
@echo " make ps - List running services"
@echo " make clean - Remove all containers, volumes, and images"
@echo " make test - Run tests in Docker environment"
@echo " make dev - Start development environment"
@echo " make shell - Open shell in app container"
@echo " make install - Install dependencies"
@echo " make install-package - Install a specific package"
@echo " make clean-deps - Clean Node.js dependencies"
@echo " make fix-install - Fix permissions and clean install"
@echo " make rebuild-modules - Force rebuild node modules with platform-specific binaries"
# start docker container
start:
${INFO} "Starting Docker container..."
${DOCKER_COMPOSE} up
# Build Docker images
build:
${INFO} "Building Docker images..."
${DOCKER_COMPOSE} build --no-cache
# Start all services
up:
${INFO} "Starting all services..."
${DOCKER_COMPOSE} up -d
${INFO} "Services are running"
${DOCKER_COMPOSE} ps
# Stop and remove containers
down:
${INFO} "Stopping all services..."
${DOCKER_COMPOSE} down
# Restart all services
restart:
${INFO} "Restarting all services..."
${DOCKER_COMPOSE} restart
# View logs
logs:
${DOCKER_COMPOSE} logs -f
# List running services
ps:
${DOCKER_COMPOSE} ps
# Clean everything
clean:
${INFO} "Cleaning up Docker resources..."
${DOCKER_COMPOSE} down -v --rmi all --remove-orphans
# Run tests
test:
${INFO} "Running tests..."
${DOCKER_COMPOSE} run --rm app npm test
# Development specific commands
dev:
${INFO} "Starting development environment..."
${DOCKER_COMPOSE} up
# Enter shell in app container
shell:
${INFO} "Opening shell in app container..."
${DOCKER_COMPOSE} exec app sh
# Install dependencies
install:
${INFO} "Installing dependencies..."
${DOCKER_COMPOSE} run --rm app npm install
# install a specific package as a dev dependency
# make install-package-dev package=drizzle-kit
install-package-dev:
${INFO} "Installing package..."
${DOCKER_COMPOSE} run --rm app npm install ${package} --save-dev
# install a specific package as a dependency
# make install-package package=drizzle-kit
install-package:
${INFO} "Installing package..."
${DOCKER_COMPOSE} run --rm app npm install --save ${package}
uninstall-package:
${INFO} "Uninstalling package..."
${DOCKER_COMPOSE} run --rm app npm uninstall ${package}
generate-migrations:
${INFO} "Generating migrations..."
${DOCKER_COMPOSE} run --rm app drizzle-kit generate --name=${name}
migrate:
${INFO} "Migrating..."
${DOCKER_COMPOSE} run --rm app npm run migrate
# Clean node modules, package-lock.json and dist
clean-deps:
${INFO} "Cleaning Node.js dependencies..."
${DOCKER_COMPOSE} run --rm app rm -rf package-lock.json node_modules dist
# Fix permissions and clean install
fix-install:
${INFO} "Fixing permissions and performing clean install..."
${DOCKER_COMPOSE} run --rm app sh -c "rm -rf node_modules package-lock.json && npm cache clean --force && npm install"
# Force rebuild node modules with platform-specific binaries
rebuild-modules:
${INFO} "Rebuilding node modules..."
${DOCKER_COMPOSE} run --rm app sh -c "npm rebuild"