Skip to content

Commit 919ae17

Browse files
nkajicmarkshusth3xx
authored
bin/docker-start helper script (#956)
Co-authored-by: Mark Shust <mark@shust.com> Co-authored-by: Dan Church <h3xx@users.noreply.github.com>
1 parent 1586e13 commit 919ae17

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ It is recommended to keep your root docker config files in one repository, and y
321321
- `bin/dev-urn-catalog-generate`: Generate URN's for PhpStorm and remap paths to local host. Restart PhpStorm after running this command.
322322
- `bin/devconsole`: Alias for `bin/n98-magerun2 dev:console`
323323
- `bin/docker-compose`: Support V1 (`docker-compose`) and V2 (`docker compose`) docker compose command, and use custom configuration files, such as `compose.yml` and `compose.dev.yml`
324+
- `bin/docker-start`: Start the Docker application (either Orbstack or Docker Desktop)
324325
- `bin/docker-stats`: Display container name and container ID, status for CPU, memory usage(in MiB and %), and memory limit of currently-running Docker containers.
325326
- `bin/download`: Download specific Magento version from Composer to the container, with optional arguments of the type ("community" [default], "enterprise", or "mageos") and version ([default] is defined in `bin/download`). Ex. `bin/download mageos` or `bin/download enterprise 2.4.7-p3`
326327
- `bin/ece-patches`: Run the Cloud Patches CLI. Ex: `bin/ece-tools apply`

compose/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ help:
3939
@echo "$(call format,dev-urn-catalog-generate,'Generate URNs for PHPStorm and remap paths to local host.')"
4040
@echo "$(call format,devconsole,'Alias for n98-magerun2 dev:console.')"
4141
@echo "$(call format,docker-compose,'Support V1 (`docker-compose`) and V2 (`docker compose`) docker compose command, and use custom configuration files.')"
42+
@echo "$(call format,docker-start,'Start the Docker application (either Orbstack or Docker Desktop)"
4243
@echo "$(call format,docker-stats,'Display status for CPU$(comma) memory usage$(comma) and memory limit of currently-running Docker containers.')"
4344
@echo "$(call format,download,'Download & extract specific Magento version to the src directory.')"
4445
@echo "$(call format,ece-patches,'Run the Cloud Patches CLI.')"

compose/bin/docker-start

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
# Function to check if Docker daemon is running
4+
docker_running() {
5+
docker stats --no-stream &> /dev/null
6+
return $?
7+
}
8+
9+
# Check if OrbStack is installed and not running
10+
if [ -d "/Applications/OrbStack.app" ]; then
11+
echo "* OrbStack is installed"
12+
13+
if (! docker_running); then
14+
echo "* Starting OrbStack..."
15+
open /Applications/OrbStack.app
16+
17+
# Wait until Docker daemon is running via OrbStack
18+
while (! docker_running); do
19+
echo "* Waiting for OrbStack to initialize Docker..."
20+
sleep 2
21+
done
22+
23+
echo "* Docker is now running via OrbStack"
24+
exit 0
25+
else
26+
echo "* Docker is already running (possibly via OrbStack)"
27+
exit 0
28+
fi
29+
fi
30+
31+
# Check if Docker Desktop is installed
32+
if [ -d "/Applications/Docker.app" ]; then
33+
echo "* Docker Desktop is installed"
34+
35+
# Check if Docker is running
36+
if (! docker_running); then
37+
echo "* Starting Docker Desktop..."
38+
open /Applications/Docker.app
39+
40+
# Wait until Docker daemon is running
41+
while (! docker_running); do
42+
echo "* Waiting for Docker Desktop to initialize..."
43+
sleep 2
44+
done
45+
46+
echo "* Docker Desktop is now running"
47+
else
48+
echo "* Docker is already running"
49+
fi
50+
else
51+
echo "* Docker Desktop is not installed. Please install Docker Desktop or OrbStack."
52+
exit 1
53+
fi

0 commit comments

Comments
 (0)