Skip to content

Commit

Permalink
Do not destroy/recreate containers every time local env is started/st…
Browse files Browse the repository at this point in the history
…opped
  • Loading branch information
delawski committed Dec 21, 2021
1 parent 2e72d97 commit 13ad512
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
27 changes: 17 additions & 10 deletions bin/local-env/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,26 @@ set -e
# Change to the expected directory
cd "$(dirname "$0")/../.."

# Check whether Node and NVM are installed
. "$(dirname "$0")/install-node-nvm.sh"
# Check if the container already exists
if [ "$(dc ps -a | grep $CONTAINER)" ]; then
echo -e "\nYour local environment has been already installed, starting now...\n"

# Check whether Composer installed
. "$(dirname "$0")/install-composer.sh"
dc start >/dev/null 2>&1
else
# Check whether Node and NVM are installed
. "$(dirname "$0")/install-node-nvm.sh"

# Check whether Docker is installed and running
. "$(dirname "$0")/launch-containers.sh"
# Check whether Composer installed
. "$(dirname "$0")/install-composer.sh"

# Set up WordPress Development site.
# Note: we don't bother installing the test site right now, because that's
# done on every time `npm run test-e2e` is run.
. "$(dirname "$0")/install-wordpress.sh"
# Check whether Docker is installed and running
. "$(dirname "$0")/launch-containers.sh"

# Set up WordPress Development site.
# Note: we don't bother installing the test site right now, because that's
# done on every time `npm run test-e2e` is run.
. "$(dirname "$0")/install-wordpress.sh"
fi

! read -d '' AMP <<"EOT"
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
Expand Down
9 changes: 7 additions & 2 deletions bin/local-env/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ if ! docker info >/dev/null 2>&1; then
fi

# Stop existing containers.
echo -e $(status_message "Stopping Docker containers...")
dc down --remove-orphans >/dev/null 2>&1
if [ "$1" == "--down" ]; then
echo -e $(status_message "Stopping and removing Docker containers...")
dc down --remove-orphans >/dev/null 2>&1
else
echo -e $(status_message "Stopping Docker containers...")
dc stop >/dev/null 2>&1
fi
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"dev": "wp-scripts start",
"env:start": "./bin/local-env/start.sh",
"env:stop": "./bin/local-env/stop.sh",
"env:down": "./bin/local-env/stop.sh --down",
"env:reset-site": "./bin/local-env/install-wordpress.sh --reset-site",
"generate-changelog": "node bin/release-changelog",
"lint": "npm-run-all --parallel lint:*",
Expand Down

0 comments on commit 13ad512

Please sign in to comment.