Skip to content

Commit 24ee1e9

Browse files
authored
Merge pull request #26 from YuriiDorosh/features/scripts
Features/scripts
2 parents 74d555a + 22f26b7 commit 24ee1e9

7 files changed

Lines changed: 81 additions & 1 deletion

File tree

Makefile

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,31 @@ nginx_docker_restart:
263263

264264
# Connect to the Nginx container
265265
nginx_shell:
266-
docker-compose exec nginx sh
266+
docker-compose exec nginx sh
267+
268+
# Scripts Commands
269+
#-------------------------------------------------
270+
271+
# Start the project with optional environment argument (e.g., make start_project ENV=production)
272+
start_project:
273+
./scripts/start_project.sh $(ENV)
274+
275+
# Stop the project
276+
stop_project:
277+
./scripts/stop_project.sh
278+
279+
# Restart the project
280+
restart_project:
281+
./scripts/restart_project.sh
282+
283+
# Run migrations
284+
migrate:
285+
./scripts/run_migrations.sh
286+
287+
# Run seeders (use SEEDER=seeder_name to specify a seeder)
288+
seed:
289+
./scripts/run_seed.sh $(SEEDER)
290+
291+
# Clear Redis cache with confirmation
292+
clear_cache:
293+
./scripts/clear_cache.sh

scripts/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```bash
2+
chmod +x *.sh
3+
```

scripts/check_docker.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Check for Docker
4+
if ! command -v docker &> /dev/null; then
5+
echo "Docker could not be found. Please install Docker."
6+
exit 1
7+
fi
8+
9+
# Check for Docker Compose
10+
if ! command -v docker-compose &> /dev/null; then
11+
echo "Docker Compose could not be found. Please install Docker Compose."
12+
exit 1
13+
fi
14+
15+
echo "Docker and Docker Compose are installed."

scripts/clear_cache.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
read -p "Are you sure you want to clear the Redis cache? [y/N] " -n 1 -r
4+
echo
5+
if [[ $REPLY =~ ^[Yy]$ ]]; then
6+
docker-compose exec redis redis-cli FLUSHALL
7+
echo "Redis cache cleared."
8+
else
9+
echo "Operation cancelled."
10+
fi

scripts/run_migrations.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
echo "Running migrations..."
4+
docker-compose exec app php spark migrate

scripts/run_seed.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
SEEDER=${1:-} # Optional seeder name as first argument
4+
5+
if [ -z "$SEEDER" ]; then
6+
echo "Running all seeders..."
7+
docker-compose exec app php spark db:seed
8+
else
9+
echo "Running seeder: $SEEDER"
10+
docker-compose exec app php spark db:seed $SEEDER
11+
fi

scripts/start_project.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
# Load Environment or use default
4+
ENVIRONMENT=${1:-development}
5+
6+
# Check Docker and Docker Compose availability
7+
./scripts/check_docker.sh || exit 1
8+
9+
echo "Starting project in $ENVIRONMENT mode..."
10+
docker-compose -f docker-compose.yml -f docker-compose.$ENVIRONMENT.yml up -d

0 commit comments

Comments
 (0)