Skip to content

Commit

Permalink
Simplified DREVOPS_DB_DOCKER_IMAGE to DREVOPS_DB_IMAGE.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Apr 29, 2024
1 parent ba7e294 commit 4a0df26
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ commands:
cmd: ahoy cli ./scripts/drevops/provision.sh

export-db:
usage: Export database dump or database image (if DREVOPS_DB_DOCKER_IMAGE variable is set).
usage: Export database dump or database image (if DREVOPS_DB_IMAGE variable is set).
cmd: ./scripts/drevops/export-db.sh "$@"

pull-db:
usage: Download database image with the latest nightly dump. Run "ahoy reload-db" to reload DB in the running stack.
cmd: \[ -n "${DREVOPS_DB_DOCKER_IMAGE}" \] && docker pull ${DREVOPS_DB_DOCKER_IMAGE} || true
cmd: \[ -n "${DREVOPS_DB_IMAGE}" \] && docker pull ${DREVOPS_DB_IMAGE} || true

reset:
usage: "Remove containers, all build files. Use with `hard` to reset repository to the last commit."
Expand Down
24 changes: 12 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ jobs:
docker compose up -d && sleep 15
docker compose exec cli mkdir -p .data && docker compose cp -L .data/db.sql cli:/app/.data/db.sql || true
docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "DREVOPS_PROVISION_POST_OPERATIONS_SKIP=1 ./scripts/drevops/provision.sh"
grep -q ^DREVOPS_DB_DOCKER_IMAGE .env && rm .data/db.sql || true
grep -q ^DREVOPS_DB_IMAGE .env && rm .data/db.sql || true
./scripts/drevops/export-db.sh db.sql
no_output_timeout: 30m
- save_cache:
Expand All @@ -196,7 +196,7 @@ jobs:
# Enforce fresh DB build (do not rely on fallback caches).
DREVOPS_CI_DB_CACHE_FALLBACK: 'no'
# Always use fresh base image for the database.
DREVOPS_DB_DOCKER_IMAGE_BASE: drevops/mariadb-drupal-data:24.3.0
DREVOPS_DB_IMAGE_BASE: drevops/mariadb-drupal-data:24.3.0
# Deploy docker image (if DREVOPS_DB_EXPORT_DOCKER_IMAGE storage is used).
DREVOPS_EXPORT_DB_DOCKER_DEPLOY_PROCEED: 1
#;> !PROVISION_USE_PROFILE
Expand Down Expand Up @@ -409,7 +409,7 @@ jobs:
#
# Switching between "database in file" (DIF, mounted data volume) and
# "database-in-Docker-image" (DIDI, data volume is a part of the image) is
# done by providing the value of DREVOPS_DB_DOCKER_IMAGE environment variable,
# done by providing the value of DREVOPS_DB_IMAGE environment variable,
# which would be set in .env file for consumer projects.
#
# Also, the source of the database can be either file (downloaded from
Expand All @@ -425,7 +425,7 @@ jobs:
# test jobs below and run them as a part of the CI system for Scaffold itself.
#
# Job to test creation of the image from DB dump file when using
# DREVOPS_DB_DOCKER_IMAGE workflow.
# DREVOPS_DB_IMAGE workflow.
scaffold-dev-didi-database-fi:
<<: *job-database
environment:
Expand All @@ -434,13 +434,13 @@ jobs:
# Use Docker database storage despite that the file is coming
# from CURL - this is to make sure that image is exported into cache
# to be used between jobs. Note that in consumer project .env file would
# have DREVOPS_DB_DOCKER_IMAGE variable set and this environment variable
# have DREVOPS_DB_IMAGE variable set and this environment variable
# would not be required.
#
# Note that here and below we are using "destination" demo image - this
# is to allow updating of this image from CI tests without jeopardizing
# main demo image.
DREVOPS_DB_DOCKER_IMAGE: drevops/drevops-mariadb-drupal-data-demo-destination-10.x
DREVOPS_DB_IMAGE: drevops/drevops-mariadb-drupal-data-demo-destination-10.x
# Use a separate tag to make sure that pushed image does not affect
# other tests (pushing broken image as 'latest' would fail other tests).
DREVOPS_DOCKER_IMAGE_TAG: scaffold-dev-didi-database-fi
Expand All @@ -457,7 +457,7 @@ jobs:
environment:
DREVOPS_DB_DOWNLOAD_SOURCE: docker_registry
DREVOPS_DB_DOWNLOAD_FORCE: 1
DREVOPS_DB_DOCKER_IMAGE: drevops/drevops-mariadb-drupal-data-demo-destination-10.x
DREVOPS_DB_IMAGE: drevops/drevops-mariadb-drupal-data-demo-destination-10.x
DREVOPS_DOCKER_IMAGE_TAG: scaffold-dev-database-ii
# Also, use this job to test pushing of the DB image to the Docker
# registry so replicate what database-nightly job would do.
Expand All @@ -466,20 +466,20 @@ jobs:
# the main workflow are separated from this one.
DREVOPS_CI_DB_CACHE_BRANCH: scaffold-dev-didi-ii
# Job to test build of the image from the previous stage of the image when
# using database-in-Docker-image workflow. Overwriting just the DREVOPS_DB_DOCKER_IMAGE
# using database-in-Docker-image workflow. Overwriting just the DREVOPS_DB_IMAGE
# variable should change the storage mechanisms, but preserve application-level
# stack operation.
scaffold-dev-didi-build-fi:
<<: *job_build
environment:
DREVOPS_DB_DOCKER_IMAGE: drevops/drevops-mariadb-drupal-data-demo-destination-10.x:drevops_dev_didi_database_fi
DREVOPS_DB_IMAGE: drevops/drevops-mariadb-drupal-data-demo-destination-10.x:drevops_dev_didi_database_fi
# Use custom cache key for this workflow to make sure that caches from
# the main workflow are separated from this one.
DREVOPS_CI_DB_CACHE_BRANCH: scaffold-dev-didi-fi
scaffold-dev-didi-build-ii:
<<: *job_build
environment:
DREVOPS_DB_DOCKER_IMAGE: drevops/drevops-mariadb-drupal-data-demo-destination-10.x:drevops_dev_database_ii
DREVOPS_DB_IMAGE: drevops/drevops-mariadb-drupal-data-demo-destination-10.x:drevops_dev_database_ii
# Use custom cache key for this workflow to make sure that caches from
# the main workflow are separated from this one.
DREVOPS_CI_DB_CACHE_BRANCH: scaffold-dev-didi-ii
Expand Down Expand Up @@ -555,15 +555,15 @@ workflows:
tags:
only: /.*/

# Test workflow to test DREVOPS_DB_DOCKER_IMAGE workflow for DB from file.
# Test workflow to test DREVOPS_DB_IMAGE workflow for DB from file.
scaffold-dev-didi-fi:
jobs:
- scaffold-dev-didi-database-fi
- scaffold-dev-didi-build-fi:
requires:
- scaffold-dev-didi-database-fi

# Test workflow to test DREVOPS_DB_DOCKER_IMAGE workflow for DB from docker registry.
# Test workflow to test DREVOPS_DB_IMAGE workflow for DB from docker registry.
scaffold-dev-didi-ii:
jobs:
- scaffold-dev-database-ii
Expand Down
10 changes: 5 additions & 5 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ DREVOPS_DB_FILE=db.sql
# Name of the pre-built Docker image.
# Uncomment to use an image with a DB data loaded into it.
# @see https://github.com/drevops/mariadb-drupal-data to seed your DB image.
# DREVOPS_DB_DOCKER_IMAGE=your_org/your_site:latest
# DREVOPS_DB_IMAGE=your_org/your_site:latest

#;< !PROVISION_USE_PROFILE
# Database can be sourced from one of the following locations:
Expand All @@ -134,7 +134,7 @@ DREVOPS_DB_FILE=db.sql
# - `none` - not downloaded, site is freshly installed for every build.

# Note that "docker_registry" works only for database-in-Docker-image
# database storage (when $DREVOPS_DB_DOCKER_IMAGE variable has a value).
# database storage (when $DREVOPS_DB_IMAGE variable has a value).
DREVOPS_DB_DOWNLOAD_SOURCE=curl

#;< DREVOPS_DB_DOWNLOAD_SOURCE_CURL
Expand Down Expand Up @@ -241,12 +241,12 @@ DREVOPS_NOTIFY_EMAIL_RECIPIENTS="[email protected]"
DREVOPS_DB_DOWNLOAD_CURL_URL=https://github.com/drevops/scaffold/releases/download/1.18.0/db_d10.demo.sql
#;> DREVOPS_DB_DOWNLOAD_SOURCE_CURL

#;< DREVOPS_DB_DOCKER_IMAGE
#;< DREVOPS_DB_IMAGE
# The name of the demo database image used for demonstration only for
# database-in-Docker-image data storage.
#; The line below will be automatically uncommented for database-in-Docker-image
#; storage. It is commented out to allow running non-database-in-Docker-image
# workflow by default.
##### DREVOPS_DB_DOCKER_IMAGE=drevops/drevops-mariadb-drupal-data-demo-10.x:latest
#;> DREVOPS_DB_DOCKER_IMAGE
##### DREVOPS_DB_IMAGE=drevops/drevops-mariadb-drupal-data-demo-10.x:latest
#;> DREVOPS_DB_IMAGE
#;> DEMO
6 changes: 3 additions & 3 deletions .scaffold/docs/.utils/variables/extra/.env.variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
# Name of the database docker image to use.
#
# See https://github.com/drevops/mariadb-drupal-data to seed your DB image.
DREVOPS_DB_DOCKER_IMAGE=
DREVOPS_DB_IMAGE=

# Name of the database fall-back docker image to use.
#
# If the image specified in $DREVOPS_DB_DOCKER_IMAGE does not exist and base
# If the image specified in $DREVOPS_DB_IMAGE does not exist and base
# image was provided - it will be used as a "clean slate" for the database.
DREVOPS_DB_DOCKER_IMAGE_BASE=
DREVOPS_DB_IMAGE_BASE=

# Drupal admin email. May need to be reset if database was sanitized.
DRUPAL_ADMIN_EMAIL="[email protected]"
Expand Down
42 changes: 21 additions & 21 deletions .scaffold/docs/content/workflows/variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -194,26 +194,6 @@ Default value: `./.data`

Defined in: `.env`, `scripts/drevops/download-db-acquia.sh`, `scripts/drevops/download-db-curl.sh`, `scripts/drevops/download-db-docker-registry.sh`, `scripts/drevops/download-db-ftp.sh`, `scripts/drevops/download-db-lagoon.sh`, `scripts/drevops/download-db.sh`, `scripts/drevops/provision.sh`

### `DREVOPS_DB_DOCKER_IMAGE`

Name of the database docker image to use.

See https://github.com/drevops/mariadb-drupal-data to seed your DB image.

Default value: `UNDEFINED`

Defined in: `.env`, `scripts/drevops/download-db-docker-registry.sh`, `scripts/drevops/export-db.sh`, `scripts/drevops/info.sh`, `scripts/drevops/provision.sh`

### `DREVOPS_DB_DOCKER_IMAGE_BASE`

Name of the database fall-back docker image to use.

If the image specified in [`$DREVOPS_DB_DOCKER_IMAGE`](#drevops_db_docker_image) does not exist and base<br />image was provided - it will be used as a "clean slate" for the database.

Default value: `UNDEFINED`

Defined in: `.env`, `scripts/drevops/download-db-docker-registry.sh`

### `DREVOPS_DB_DOWNLOAD_ACQUIA_DB_NAME`

Acquia database name to download the database from.
Expand Down Expand Up @@ -354,7 +334,7 @@ Defined in: `scripts/drevops/download-db-lagoon.sh`

### `DREVOPS_DB_DOWNLOAD_SOURCE`

Note that "docker_registry" works only for database-in-Docker-image<br />database storage (when [`$DREVOPS_DB_DOCKER_IMAGE`](#drevops_db_docker_image) variable has a value).
Note that "docker_registry" works only for database-in-Docker-image<br />database storage (when [`$DREVOPS_DB_IMAGE`](#drevops_db_image) variable has a value).

Default value: `curl`

Expand Down Expand Up @@ -432,6 +412,26 @@ Default value: `db.sql`

Defined in: `.env`, `scripts/drevops/download-db-acquia.sh`, `scripts/drevops/download-db-curl.sh`, `scripts/drevops/download-db-ftp.sh`, `scripts/drevops/download-db-lagoon.sh`, `scripts/drevops/provision.sh`

### `DREVOPS_DB_IMAGE`

Name of the database docker image to use.

See https://github.com/drevops/mariadb-drupal-data to seed your DB image.

Default value: `UNDEFINED`

Defined in: `.env`, `scripts/drevops/download-db-docker-registry.sh`, `scripts/drevops/export-db.sh`, `scripts/drevops/info.sh`, `scripts/drevops/provision.sh`

### `DREVOPS_DB_IMAGE_BASE`

Name of the database fall-back docker image to use.

If the image specified in [`$DREVOPS_DB_IMAGE`](#drevops_db_image) does not exist and base<br />image was provided - it will be used as a "clean slate" for the database.

Default value: `UNDEFINED`

Defined in: `.env`, `scripts/drevops/download-db-docker-registry.sh`

### `DREVOPS_DEBUG`

Set to `1` to print debug information in DrevOps scripts.
Expand Down
2 changes: 1 addition & 1 deletion .scaffold/tests/bats/_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ setup() {

# Isolate variables set in CI.
unset DREVOPS_DB_DOWNLOAD_SOURCE
unset DREVOPS_DB_DOCKER_IMAGE
unset DREVOPS_DB_IMAGE
unset DREVOPS_DB_DOWNLOAD_FORCE
# Tokens required for tests are set explicitly within each tests with a TEST_ prefix.
unset GITHUB_TOKEN
Expand Down
2 changes: 1 addition & 1 deletion .scaffold/tests/bats/docker-compose.bats
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ load _helper.bash

echo "COMPOSE_PROJECT_NAME=the_matrix" >>.env
echo "DREVOPS_WEBROOT=docroot" >>.env
echo "DREVOPS_DB_DOCKER_IMAGE=myorg/my_db_image" >>.env
echo "DREVOPS_DB_IMAGE=myorg/my_db_image" >>.env
echo "XDEBUG_ENABLE=1" >>.env
echo "SSMTP_MAILHUB=false" >>.env
echo "DRUPAL_SHIELD_USER=jane" >>.env
Expand Down
8 changes: 4 additions & 4 deletions .scaffold/tests/bats/install.initial.bats
Original file line number Diff line number Diff line change
Expand Up @@ -221,24 +221,24 @@ load _helper.bash
@test "Install into empty directory; db from curl; storage is Docker image" {
export DREVOPS_DB_DOWNLOAD_SOURCE=curl

export DREVOPS_DB_DOCKER_IMAGE="drevops/drevops-mariadb-drupal-data-demo-10.x:latest"
export DREVOPS_DB_IMAGE="drevops/drevops-mariadb-drupal-data-demo-10.x:latest"

run_installer_quiet

assert_file_contains ".env" "DREVOPS_DB_DOWNLOAD_SOURCE=curl"
assert_file_contains ".env" "DREVOPS_DB_DOWNLOAD_CURL_URL="
assert_file_contains ".env" "DREVOPS_DB_DOCKER_IMAGE=drevops/drevops-mariadb-drupal-data-demo-10.x:latest"
assert_file_contains ".env" "DREVOPS_DB_IMAGE=drevops/drevops-mariadb-drupal-data-demo-10.x:latest"
}

@test "Install into empty directory; db from Docker image; storage is Docker image" {
export DREVOPS_DB_DOWNLOAD_SOURCE=docker_registry
export DREVOPS_DB_DOCKER_IMAGE="drevops/drevops-mariadb-drupal-data-demo-10.x:latest"
export DREVOPS_DB_IMAGE="drevops/drevops-mariadb-drupal-data-demo-10.x:latest"

run_installer_quiet

assert_file_contains ".env" "DREVOPS_DB_DOWNLOAD_SOURCE=docker_registry"
assert_file_not_contains ".env" "DREVOPS_DB_DOWNLOAD_CURL_URL="
assert_file_contains ".env" "DREVOPS_DB_DOCKER_IMAGE=drevops/drevops-mariadb-drupal-data-demo-10.x:latest"
assert_file_contains ".env" "DREVOPS_DB_IMAGE=drevops/drevops-mariadb-drupal-data-demo-10.x:latest"
}

@test "Install into empty directory; DrevOps scripts are not modified" {
Expand Down
8 changes: 4 additions & 4 deletions .scaffold/tests/bats/workflow.storage.curl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ load _helper.workflow.bash
# @todo: build.sh may need to have a support to create a local image if
# it does not exist.
# Use a test image. Image always must use a tag.
export DREVOPS_DB_DOCKER_IMAGE="drevops/drevops-mariadb-drupal-data-test-10.x:latest"
export DREVOPS_DB_IMAGE="drevops/drevops-mariadb-drupal-data-test-10.x:latest"

# Explicitly specify that we do not want to login into the public registry
# to use test image.
Expand All @@ -42,15 +42,15 @@ load _helper.workflow.bash
assert_file_not_exists .data/db.sql

substep "Remove any existing images to download the fresh one."
docker_remove_image "${DREVOPS_DB_DOCKER_IMAGE}"
docker_remove_image "${DREVOPS_DB_IMAGE}"

prepare_sut "Starting download from curl, storage in Docker image cached WORKFLOW tests in build directory ${BUILD_DIR}"
assert_file_exists .data/db.sql

assert_file_contains ".env" "DREVOPS_DB_DOWNLOAD_SOURCE=curl"
assert_file_contains ".env" "DREVOPS_DB_DOCKER_IMAGE=${DREVOPS_DB_DOCKER_IMAGE}"
assert_file_contains ".env" "DREVOPS_DB_IMAGE=${DREVOPS_DB_IMAGE}"
# Assert that demo config was removed as a part of the installation.
assert_file_not_contains ".env" "DREVOPS_DB_DOCKER_IMAGE=drevops/drevops-mariadb-drupal-data-demo-10.x:latest"
assert_file_not_contains ".env" "DREVOPS_DB_IMAGE=drevops/drevops-mariadb-drupal-data-demo-10.x:latest"
assert_file_contains ".env" "DREVOPS_DB_DOWNLOAD_CURL_URL="

assert_ahoy_build
Expand Down
10 changes: 5 additions & 5 deletions .scaffold/tests/bats/workflow.storage.image.bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ load _helper.workflow.bash
export DREVOPS_DB_DOWNLOAD_SOURCE=docker_registry

# Use a test image. Image always must use a tag.
export DREVOPS_DB_DOCKER_IMAGE="drevops/drevops-mariadb-drupal-data-test-10.x:latest"
export DREVOPS_DB_IMAGE="drevops/drevops-mariadb-drupal-data-test-10.x:latest"

# Do not use demo database - testing demo database discovery is another test.
export DREVOPS_INSTALL_DEMO_SKIP=1
Expand All @@ -38,7 +38,7 @@ load _helper.workflow.bash
assert_file_not_exists .data/db.sql

substep "Remove any existing images to download the fresh one."
docker_remove_image "${DREVOPS_DB_DOCKER_IMAGE}"
docker_remove_image "${DREVOPS_DB_IMAGE}"

prepare_sut "Starting download from image, storage in docker image WORKFLOW tests in build directory ${BUILD_DIR}"

Expand All @@ -48,9 +48,9 @@ load _helper.workflow.bash
rm .env.local >/dev/null

assert_file_contains ".env" "DREVOPS_DB_DOWNLOAD_SOURCE=docker_registry"
assert_file_contains ".env" "DREVOPS_DB_DOCKER_IMAGE=${DREVOPS_DB_DOCKER_IMAGE}"
assert_file_contains ".env" "DREVOPS_DB_IMAGE=${DREVOPS_DB_IMAGE}"
# Assert that demo config was removed as a part of the installation.
assert_file_not_contains ".env" "DREVOPS_DB_DOCKER_IMAGE=drevops/drevops-mariadb-drupal-data-demo-10.x:latest"
assert_file_not_contains ".env" "DREVOPS_DB_IMAGE=drevops/drevops-mariadb-drupal-data-demo-10.x:latest"
assert_file_not_contains ".env" "DREVOPS_DB_DOWNLOAD_CURL_URL="

assert_ahoy_build
Expand All @@ -71,7 +71,7 @@ load _helper.workflow.bash
# Other stack assertions - these run only for this Docker image-related test.
assert_gitignore

assert_ahoy_info "web" "${DREVOPS_DB_DOCKER_IMAGE}"
assert_ahoy_info "web" "${DREVOPS_DB_IMAGE}"

assert_ahoy_docker_logs

Expand Down
Loading

1 comment on commit 4a0df26

@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.