diff --git a/.github/workflows/continous-delivery.yml b/.github/workflows/continous-delivery.yml index a8487dc3..7a3e2f97 100644 --- a/.github/workflows/continous-delivery.yml +++ b/.github/workflows/continous-delivery.yml @@ -18,6 +18,7 @@ on: description: 'Network to deploy: Mainnet or Testnet' required: true log_file: + default: '' description: 'Log to a file path rather than standard output' no_cache: description: 'Disable the Docker cache for this build' @@ -217,7 +218,7 @@ jobs: --user-output-enabled \ --metadata google-logging-enabled=true,google-logging-use-fluentbit=true \ --container-image ${{ vars.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }} \ - --container-env "NETWORK=${{ matrix.network }},LOG_FILE=${{ vars.CD_LOG_FILE }},SENTRY_DSN=${{ vars.SENTRY_DSN }},SHORT_SHA=${{ env.GITHUB_SHA_SHORT }}" \ + --container-env "NETWORK=${{ matrix.network }},LOG_FILE=${{ vars.CD_LOG_FILE }},LOG_COLOR=false,SENTRY_DSN=${{ vars.SENTRY_DSN }},SHORT_SHA=${{ env.GITHUB_SHA_SHORT }}" \ --create-disk=name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},auto-delete=yes,size=300GB,type=pd-ssd \ --container-mount-disk=mount-path="/zebrad-cache",name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK} \ --machine-type ${{ vars.GCP_SMALL_MACHINE }} \ @@ -318,7 +319,7 @@ jobs: --container-stdin \ --container-tty \ --container-image ${{ vars.GAR_BASE }}/zebrad@${{ needs.build.outputs.image_digest }} \ - --container-env "NETWORK=${{ inputs.network }},LOG_FILE=${{ inputs.log_file || vars.CD_LOG_FILE }},SENTRY_DSN=${{ vars.SENTRY_DSN }},SHORT_SHA=${{ env.GITHUB_SHA_SHORT }}" \ + --container-env "NETWORK=${{ inputs.network }},LOG_FILE=${{ inputs.log_file }},LOG_COLOR=false,SENTRY_DSN=${{ vars.SENTRY_DSN }},SHORT_SHA=${{ env.GITHUB_SHA_SHORT }}" \ --create-disk=auto-delete=yes,size=300GB,type=pd-ssd \ --create-disk=name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK},auto-delete=yes,size=300GB,type=pd-ssd \ --container-mount-disk=mount-path='/zebrad-cache',name=zebrad-cache-${{ env.GITHUB_SHA_SHORT }}-${NETWORK} \ diff --git a/docker/Dockerfile b/docker/Dockerfile index 012fa674..f0f4ae52 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -162,6 +162,12 @@ ENV RPC_PORT ${RPC_PORT} ARG LOG_FILE ENV LOG_FILE ${LOG_FILE} +# Zebra automatically detects if it is attached to a terminal, and uses colored output. +# Set this to 'true' to force using color even if the output is not a terminal. +# Set this to 'false' to disable using color even if the output is a terminal. +ARG LOG_COLOR +ENV LOG_COLOR ${LOG_COLOR} + # Expose configured ports EXPOSE 8233 18233 $RPC_PORT diff --git a/docker/runtime-entrypoint.sh b/docker/runtime-entrypoint.sh index a91f4ea2..fbac0849 100755 --- a/docker/runtime-entrypoint.sh +++ b/docker/runtime-entrypoint.sh @@ -53,13 +53,28 @@ listen_addr = "0.0.0.0:${RPC_PORT}" EOF fi +if [[ -n "$LOG_FILE" ]] || [[ -n "$LOG_COLOR" ]]; then +cat <> "$ZEBRA_CONF_PATH" +[tracing] +#endpoint_addr = "0.0.0.0:3000" +EOF +fi + if [[ -n "$LOG_FILE" ]]; then mkdir -p $(dirname "$LOG_FILE") cat <> "$ZEBRA_CONF_PATH" -[tracing] log_file = "${LOG_FILE}" -#endpoint_addr = "0.0.0.0:3000" +EOF +fi + +if [[ "$LOG_COLOR" = "true" ]]; then +cat <> "$ZEBRA_CONF_PATH" +force_use_color = true +EOF +elif [[ "$LOG_COLOR" = "false" ]]; then +cat <> "$ZEBRA_CONF_PATH" +use_color = false EOF fi