Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1144] Added support for .env.local in docker-compose. #1196

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ DREVOPS_DB_DOWNLOAD_FORCE=
# Set to `1` to print debug information in DrevOps scripts.
DREVOPS_DEBUG=

# Set to `1` to print debug information from Docker build.
DREVOPS_DOCKER_VERBOSE=

# Set to `y` to suppress Ahoy prompts.
AHOY_CONFIRM_RESPONSE=

Expand Down
3 changes: 0 additions & 3 deletions .drevops/docs/.utils/variables/extra/.env.variables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ DRUPAL_SITE_NAME="${DREVOPS_PROJECT}"
# Used only when installing from profile.
DRUPAL_SITE_EMAIL="[email protected]"

# Print output from Docker build.
DREVOPS_DOCKER_VERBOSE=1

# Print output from Composer install.
DREVOPS_COMPOSER_VERBOSE=1

Expand Down
10 changes: 1 addition & 9 deletions .drevops/docs/content/workflows/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Defined in: `.env.local.default`

### `AHOY_CONFIRM_WAIT_SKIP`

When Ahoy prompts are suppressed ([`$AHOY_CONFIRM`](#AHOY_CONFIRM_RESPONSE) is `1`), the command<br />will wait for `3` seconds before proceeding.<br />Set this variable to "`1`" to skip the wait.
When Ahoy prompts are suppressed ([`$AHOY_CONFIRM_RESPONSE`](#AHOY_CONFIRM_RESPONSE) is `1`), the command<br />will wait for `3` seconds before proceeding.<br />Set this variable to "`1`" to skip the wait.

Default value: `1`

Expand Down Expand Up @@ -685,14 +685,6 @@ Default value: `latest`

Defined in: `scripts/drevops/deploy-docker.sh`

### `DREVOPS_DOCKER_VERBOSE`

Set to `1` to print debug information from Docker build.

Default value: `UNDEFINED`

Defined in: `.env.local.default`, `.env`

### `DREVOPS_DOCTOR_CHECK_BOOTSTRAP`

Default value: `UNDEFINED`
Expand Down
3 changes: 0 additions & 3 deletions .drevops/tests/bats/_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ setup() {

# Allow to override debug variables from environment when developing tests.
export DREVOPS_DEBUG="${TEST_DREVOPS_DEBUG:-}"
export DREVOPS_DOCKER_VERBOSE="${TEST_DREVOPS_DOCKER_VERBOSE:-}"
export DREVOPS_COMPOSER_VERBOSE="${TEST_DREVOPS_COMPOSER_VERBOSE:-}"
export DREVOPS_NPM_VERBOSE="${TEST_DREVOPS_NPM_VERBOSE:-}"
export DREVOPS_INSTALL_DEBUG="${TEST_DREVOPS_INSTALL_DEBUG:-}"

# Switch to using test demo DB.
Expand Down
27 changes: 27 additions & 0 deletions .drevops/tests/bats/docker-compose.bats
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ load _helper.bash
assert_files_equal docker-compose.actual.json docker-compose.env_mod.json
}

@test "Docker Compose: default with .env and .env.local" {
prepare_docker_compose

cp "${ROOT_DIR}/.env" .env
cp "${ROOT_DIR}/.env.local.default" .env.local

substep "Validate configuration"
run docker compose -f docker-compose.yml config
assert_success

substep "Compare with fixture"
prepare_docker_compose_fixtures

docker compose -f docker-compose.yml config --format json >docker-compose.actual.json
process_docker_compose_json docker-compose.actual.json
update_docker_compose_fixture "${PWD}"/docker-compose.actual.json docker-compose.env_local.json

assert_files_equal docker-compose.actual.json docker-compose.env_local.json
}

# Prepare current docker compose file for testing.
prepare_docker_compose() {
cp "${ROOT_DIR}/docker-compose.yml" docker-compose.yml
Expand All @@ -92,6 +112,7 @@ prepare_docker_compose_fixtures() {
cp "${ROOT_DIR}/.drevops/tests/bats/fixtures/docker-compose.env.json" docker-compose.env.json
cp "${ROOT_DIR}/.drevops/tests/bats/fixtures/docker-compose.env_mod.json" docker-compose.env_mod.json
cp "${ROOT_DIR}/.drevops/tests/bats/fixtures/docker-compose.noenv.json" docker-compose.noenv.json
cp "${ROOT_DIR}/.drevops/tests/bats/fixtures/docker-compose.env_local.json" docker-compose.env_local.json
replace_string_content "FIXTURE_CUR_DIR" "${CURRENT_PROJECT_DIR}" "${CURRENT_PROJECT_DIR}"

# Replace symlink /private paths in MacOS.
Expand Down Expand Up @@ -127,6 +148,12 @@ process_docker_compose_json() {
}
});

array_walk_recursive(\$data, function (&\$value) {
if (\$value !== null && str_contains(\$value, \"$HOME\")) {
\$value = str_replace(\"$HOME\", 'HOME', \$value);
}
});

\$data = json_encode(\$data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

print \$data;
Expand Down
210 changes: 210 additions & 0 deletions .drevops/tests/bats/fixtures/docker-compose.env.json

Large diffs are not rendered by default.

Loading
Loading