Skip to content

Commit

Permalink
SC-15697: Install the Blackfire client into the CLI, only when an Bla…
Browse files Browse the repository at this point in the history
…ckfire extension is enabled. (spryker#464)
  • Loading branch information
zyuzka authored Sep 5, 2023
1 parent 90268f5 commit 6a94e22
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
15 changes: 15 additions & 0 deletions bin/lib/bool.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

function Bool::normalizeBashBool() {
case "${1}" in
${TRUE})
echo -n 1
;;
${FALSE})
echo -n 0
;;
*)
Console::error "Unknown boolean value \"${1}\". Use \${TRUE} or \${FALSE}."
;;
esac
}
4 changes: 3 additions & 1 deletion bin/sdk/images/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

require docker

import lib/bool.sh

function Images::pull() {
docker pull "${SPRYKER_PLATFORM_IMAGE}" || true
}
Expand Down Expand Up @@ -103,13 +105,13 @@ function Images::_buildApp() {
fi

Console::verbose "${INFO}Building CLI images${NC}"

docker build \
-t "${baseCliImage}" \
-t "${pipelineImage}" \
-f "${DEPLOYMENT_PATH}/images/common/cli/Dockerfile" \
--progress="${PROGRESS_TYPE}" \
--build-arg "SPRYKER_PARENT_IMAGE=${localAppImage}" \
--build-arg "BLACKFIRE_EXTENSION_ENABLED=$(Bool::normalizeBashBool ${BLACKFIRE_EXTENSION_ENABLED})" \
"${DEPLOYMENT_PATH}/context" 1>&2

docker build \
Expand Down
9 changes: 6 additions & 3 deletions images/common/cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ ARG SPRYKER_PARENT_IMAGE

FROM ${SPRYKER_PARENT_IMAGE} as cli-basic

ARG BLACKFIRE_EXTENSION_ENABLED=0

# Blackfire client
RUN mkdir -p /tmp/blackfire \
RUN bash -c 'if [ ${BLACKFIRE_EXTENSION_ENABLED} = 1 ]; then \
mkdir -p /tmp/blackfire \
&& architecture=$(case $(uname -m) in i386 | i686 | x86) echo "i386" ;; x86_64 | amd64) echo "amd64" ;; aarch64 | arm64 | armv8) echo "arm64" ;; *) echo "amd64" ;; esac) \
&& curl -A "Docker" -L https://blackfire.io/api/v1/releases/cli/linux/$architecture | tar zxp -C /tmp/blackfire \
&& wget -qO- -U "Docker" https://blackfire.io/api/v1/releases/cli/linux/$architecture | tar zxp -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire /usr/bin/blackfire \
&& rm -Rf /tmp/blackfire
&& rm -Rf /tmp/blackfire; fi'

ENV PATH=/data/vendor/bin:$PATH

Expand Down

0 comments on commit 6a94e22

Please sign in to comment.