Skip to content

Commit

Permalink
[#1279] Remove DB copy from ahoy provision.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Apr 25, 2024
1 parent 305b385 commit e2882b0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
7 changes: 1 addition & 6 deletions .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,7 @@ commands:
provision:
usage: Provision a site from the database dump or profile.
cmd: |
if [ -f .data/db.sql ]; then
docker compose exec cli mkdir -p .data
docker compose cp -L .data/db.sql cli:/app/.data/db.sql
fi
ahoy cli ./scripts/drevops/provision.sh
cmd: ahoy cli ./scripts/drevops/provision.sh

export-db:
usage: Export database dump or database image (if DREVOPS_DB_DOCKER_IMAGE variable is set).
Expand Down
10 changes: 10 additions & 0 deletions .scaffold/tests/bats/_helper.workflow.bash
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ assert_ahoy_build() {
export DOCKER_USER="${TEST_DOCKER_USER?Test Docker user is not set}"
export DOCKER_PASS="${TEST_DOCKER_PASS?Test Docker pass is not set}"

if [ "${SCAFFOLD_DEV_VOLUMES_MOUNTED}" != "1" ]; then
# Override the provision command in .ahoy.yml to copy the database file to
# the container for when the volumes are not mounted.
# We are doing this only to replicate developer's workflow and experience
# when they run `ahoy build` locally.
local sed_opts
sed_opts=(-i) && [ "$(uname)" = "Darwin" ] && sed_opts=(-i '')
sed "${sed_opts[@]}" 's|cmd: ahoy cli ./scripts/drevops/provision.sh|cmd: if [ -f .data/db.sql ]; then docker compose exec cli mkdir -p .data; docker compose cp -L .data/db.sql cli:/app/.data/db.sql; fi; ahoy cli \.\/scripts\/drevops\/provision\.sh|g' .ahoy.yml
fi

run ahoy build
run sync_to_host

Expand Down
12 changes: 9 additions & 3 deletions .scaffold/tests/bats/workflow.smoke.bats
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ load _helper.workflow.bash
docker compose exec -T cli composer install --prefer-dist >&3

substep "Provisioning"
if [ -f .data/db.sql ]; then
docker compose exec cli mkdir -p .data
docker compose cp -L .data/db.sql cli:/app/.data/db.sql

# Copy DB into container for the cases when the volumes are not mounted.
# This will not be a case locally.
if [ "${SCAFFOLD_DEV_VOLUMES_MOUNTED}" != "1" ]; then
if [ -f .data/db.sql ]; then
docker compose exec cli mkdir -p .data
docker compose cp -L .data/db.sql cli:/app/.data/db.sql
fi
fi

docker compose exec -T cli ./scripts/drevops/provision.sh >&3

sync_to_host
Expand Down

1 comment on commit e2882b0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.