diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 3a379cc05b..043f4e825b 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -1,7 +1,6 @@ env: SETUP_GVM_VERSION: 'v0.5.1' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151 - ELASTIC_PACKAGE_COMPOSE_DISABLE_ANSI: "true" - ELASTIC_PACKAGE_COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION: "true" + ELASTIC_PACKAGE_COMPOSE_DISABLE_VERBOSE_OUTPUT: "true" DOCKER_COMPOSE_VERSION: "v2.24.1" DOCKER_VERSION: "24.0.7" KIND_VERSION: 'v0.20.0' diff --git a/README.md b/README.md index b557fd28fc..eae32b5a67 100644 --- a/README.md +++ b/README.md @@ -625,6 +625,48 @@ The following settings are available per profile: * `stack.serverless.region` can be used to select the region to use when starting serverless projects. +## Useful environment variables + +There are available some environment variables that could be used to change some of the +`elastic-package` settings: + +- Related to `docker-compose` / `docker compose` commands: + - `ELASTIC_PACKAGE_COMPOSE_DISABLE_VERBOSE_OUTPUT`: If set to `true`, it disables the progress output from `docker compose`/`docker-compose` commands. + - For versions v2 `< 2.19.0`, it sets `--ansi never` flag. + - For versions v2 `>= 2.19.0`, it sets `--progress plain` flag and `--quiet-pull` for `up` sub-command`. + + +- Related to global `elastic-package` settings: + - `ELASTIC_PACKAGE_CHECK_UPDATE_DISABLED`: if set to `true`, `elastic-package` is not going to check + for newer versions. + - `ELASTIC_PACKAGE_PROFILE`: Name of the profile to be using. + - `ELASTIC_PACKAGE_DATA_HOME`: Custom path to be used for `elastic-package` data directory. By default this is `~/.elastic-package`. + +- Related to the build process: + - `ELASTIC_PACKAGE_REPOSITORY_LICENSE`: Path to the default repository license. + - `ELASTIC_PACKAGE_LINKS_FILE_PATH`: Path to the links table file (e.g. `links_table.yml`) with the link definitions to be used in the build process of a package. + +- Related to signing packages: + - `ELASTIC_PACKAGE_SIGNER_PRIVATE_KEYFILE`: Path to the private key file to sign packages. + - `ELASTIC_PACKAGE_SIGNER_PASSPHRASE`: Passphrase to use the private key file. + +- Related to tests: + - `ELASTIC_PACKAGE_SERVERLESS_PIPELINE_TEST_DISABLE_COMPARE_RESULTS`: If set to `true`, the results from pipeline tests are not compared to avoid errors from GeoIP. + +- To configure the Elastic stack to be used by `elastic-package`: + - `ELASTIC_PACKAGE_ELASTICSEARCH_HOST`: Host of the elasticsearch (e.g. https://127.0.0.1:9200) + - `ELASTIC_PACKAGE_ELASTICSEARCH_USERNAME`: User name to connect to elasticsearch (e.g. elastic) + - `ELASTIC_PACKAGE_ELASTICSEARCH_PASSWORD`: Password of that user. + - `ELASTIC_PACKAGE_ELASTICSEARCH_KIBANA_HOST`: Kibana URL (e.g. https://127.0.0.1:5601) + - `ELASTIC_PACKAGE_ELASTICSEARCH_CA_CERT`: Path to the CA certificate to connect to the Elastic stack services. + +- To configure an external metricstore while running benchmarks (more info at [system benchmarking docs](https://github.com/elastic/elastic-package/blob/main/docs/howto/system_benchmarking.md#setting-up-an-external-metricstore) or [rally benchmarking docs](https://github.com/elastic/elastic-package/blob/main/docs/howto/rally_benchmarking.md#setting-up-an-external-metricstore)): + - `ELASTIC_PACKAGE_ESMETRICSTORE_HOST`: Host of the elasticsearch (e.g. https://127.0.0.1:9200) + - `ELASTIC_PACKAGE_ESMETRICSTORE_USERNAME`: Username to connect to elasticsearch (e.g. elastic) + - `ELASTIC_PACKAGE_ESMETRICSTORE_PASSWORD`: Password for the user. + - `ELASTIC_PACKAGE_ESMETRICSTORE_CA_CERT`: Path to the CA certificate to connect to the Elastic stack services. + + ## Release process This project uses [GoReleaser](https://goreleaser.com/) to release a new version of the application (semver). Release publishing diff --git a/internal/compose/compose.go b/internal/compose/compose.go index 87e512e290..9b8ceda59b 100644 --- a/internal/compose/compose.go +++ b/internal/compose/compose.go @@ -33,9 +33,12 @@ const ( ) var ( - DisableANSIComposeEnv = environment.WithElasticPackagePrefix("COMPOSE_DISABLE_ANSI") - DisablePullProgressInformationEnv = environment.WithElasticPackagePrefix("COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION") - EnableComposeStandaloneEnv = environment.WithElasticPackagePrefix("COMPOSE_ENABLE_STANDALONE") + EnableComposeStandaloneEnv = environment.WithElasticPackagePrefix("COMPOSE_ENABLE_STANDALONE") + DisableVerboseOutputComposeEnv = environment.WithElasticPackagePrefix("COMPOSE_DISABLE_VERBOSE_OUTPUT") +) + +const ( + defaultComposeProgressOutput = "plain" ) // Project represents a Docker Compose project. @@ -47,6 +50,8 @@ type Project struct { dockerComposeStandalone bool disableANSI bool disablePullProgressInformation bool + progressOutput string + composeVersion *semver.Version } // Config represents a Docker Compose configuration file. @@ -204,13 +209,16 @@ func NewProject(name string, paths ...string) (*Project, error) { } logger.Debug(versionMessage) - v, ok = os.LookupEnv(DisableANSIComposeEnv) + v, ok = os.LookupEnv(DisableVerboseOutputComposeEnv) if !c.dockerComposeV1 && ok && strings.ToLower(v) != "false" { - c.disableANSI = true - } - - v, ok = os.LookupEnv(DisablePullProgressInformationEnv) - if ok && strings.ToLower(v) != "false" { + if c.composeVersion.LessThan(semver.MustParse("2.19.0")) { + c.disableANSI = true + } else { + // --ansi never looks is ignored by "docker compose" and latest versions of "docker-compose" + // adding --progress plain is a similar result as --ansi never + // if set to "--progress quiet", there is no output at all from docker compose commands + c.progressOutput = defaultComposeProgressOutput + } c.disablePullProgressInformation = true } @@ -442,6 +450,10 @@ func (p *Project) baseArgs() []string { args = append(args, "--ansi", "never") } + if p.progressOutput != "" { + args = append(args, "--progress", p.progressOutput) + } + args = append(args, "-p", p.name) return args } @@ -504,6 +516,7 @@ func (p *Project) dockerComposeVersion() (*semver.Version, error) { if err != nil { return nil, fmt.Errorf("docker compose version is not a valid semver (value: %s): %w", dcVersion, err) } + p.composeVersion = ver return ver, nil } diff --git a/tools/readme/readme.md.tmpl b/tools/readme/readme.md.tmpl index ede02ded38..4f83703227 100644 --- a/tools/readme/readme.md.tmpl +++ b/tools/readme/readme.md.tmpl @@ -178,6 +178,48 @@ The following settings are available per profile: * `stack.serverless.region` can be used to select the region to use when starting serverless projects. +## Useful environment variables + +There are available some environment variables that could be used to change some of the +`elastic-package` settings: + +- Related to `docker-compose` / `docker compose` commands: + - `ELASTIC_PACKAGE_COMPOSE_DISABLE_VERBOSE_OUTPUT`: If set to `true`, it disables the progress output from `docker compose`/`docker-compose` commands. + - For versions v2 `< 2.19.0`, it sets `--ansi never` flag. + - For versions v2 `>= 2.19.0`, it sets `--progress plain` flag and `--quiet-pull` for `up` sub-command`. + + +- Related to global `elastic-package` settings: + - `ELASTIC_PACKAGE_CHECK_UPDATE_DISABLED`: if set to `true`, `elastic-package` is not going to check + for newer versions. + - `ELASTIC_PACKAGE_PROFILE`: Name of the profile to be using. + - `ELASTIC_PACKAGE_DATA_HOME`: Custom path to be used for `elastic-package` data directory. By default this is `~/.elastic-package`. + +- Related to the build process: + - `ELASTIC_PACKAGE_REPOSITORY_LICENSE`: Path to the default repository license. + - `ELASTIC_PACKAGE_LINKS_FILE_PATH`: Path to the links table file (e.g. `links_table.yml`) with the link definitions to be used in the build process of a package. + +- Related to signing packages: + - `ELASTIC_PACKAGE_SIGNER_PRIVATE_KEYFILE`: Path to the private key file to sign packages. + - `ELASTIC_PACKAGE_SIGNER_PASSPHRASE`: Passphrase to use the private key file. + +- Related to tests: + - `ELASTIC_PACKAGE_SERVERLESS_PIPELINE_TEST_DISABLE_COMPARE_RESULTS`: If set to `true`, the results from pipeline tests are not compared to avoid errors from GeoIP. + +- To configure the Elastic stack to be used by `elastic-package`: + - `ELASTIC_PACKAGE_ELASTICSEARCH_HOST`: Host of the elasticsearch (e.g. https://127.0.0.1:9200) + - `ELASTIC_PACKAGE_ELASTICSEARCH_USERNAME`: User name to connect to elasticsearch (e.g. elastic) + - `ELASTIC_PACKAGE_ELASTICSEARCH_PASSWORD`: Password of that user. + - `ELASTIC_PACKAGE_ELASTICSEARCH_KIBANA_HOST`: Kibana URL (e.g. https://127.0.0.1:5601) + - `ELASTIC_PACKAGE_ELASTICSEARCH_CA_CERT`: Path to the CA certificate to connect to the Elastic stack services. + +- To configure an external metricstore while running benchmarks (more info at [system benchmarking docs](https://github.com/elastic/elastic-package/blob/main/docs/howto/system_benchmarking.md#setting-up-an-external-metricstore) or [rally benchmarking docs](https://github.com/elastic/elastic-package/blob/main/docs/howto/rally_benchmarking.md#setting-up-an-external-metricstore)): + - `ELASTIC_PACKAGE_ESMETRICSTORE_HOST`: Host of the elasticsearch (e.g. https://127.0.0.1:9200) + - `ELASTIC_PACKAGE_ESMETRICSTORE_USERNAME`: Username to connect to elasticsearch (e.g. elastic) + - `ELASTIC_PACKAGE_ESMETRICSTORE_PASSWORD`: Password for the user. + - `ELASTIC_PACKAGE_ESMETRICSTORE_CA_CERT`: Path to the CA certificate to connect to the Elastic stack services. + + ## Release process This project uses [GoReleaser](https://goreleaser.com/) to release a new version of the application (semver). Release publishing