Skip to content

Commit 7a31199

Browse files
authored
Merge pull request #347 from pact-foundation/feat/add-scarf-analytics
feat: add scarf analytics
2 parents f301922 + 5d0e65b commit 7a31199

5 files changed

Lines changed: 24 additions & 3 deletions

File tree

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ FROM base-$TARGETARCH AS pb-dev
2121
ARG TARGETARCH
2222
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.47/supercronic-linux-${TARGETARCH} \
2323
SUPERCRONIC=supercronic-linux-${TARGETARCH}
24+
25+
# Scarf analytics - version/platform reported by the entrypoint on startup
26+
ARG VERSION=dev
27+
ENV PACT_BROKER_DOCKER_VERSION=${VERSION} \
28+
PACT_BROKER_DOCKER_PLATFORM=linux-${TARGETARCH}
2429
RUN wget "$SUPERCRONIC_URL" \
2530
&& echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - \
2631
&& chmod +x "$SUPERCRONIC" \

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,18 @@ See the [Troubleshooting][troubleshooting] page on the docs site.
323323

324324
## Anonymized analytics
325325

326-
`pactfoundation/pact-broker` uses [Scarf](https://scarf.sh/) to collect [anonymized download analytics](https://about.scarf.sh/about). These analytics help support the maintainers of this image and ONLY run when you pull the image through the Scarf gateway (the pull commands shown throughout this README). To opt out, pull the image directly from Docker Hub:
326+
`pactfoundation/pact-broker` uses [Scarf](https://scarf.sh/) to collect anonymized analytics that help support the maintainers of this image. Two things are tracked, independently of one another:
327+
328+
* A README impression pixel, served from `static.scarf.sh`.
329+
* A lightweight, anonymous ping (image version + platform) sent by the container's entrypoint on every startup.
330+
331+
To opt out of the startup ping, set either `PACT_DO_NOT_TRACK` or `SCARF_NO_ANALYTICS` to any non-empty value when running the container:
327332

328333
```sh
329-
docker pull pactfoundation/pact-broker
334+
docker run --rm -e PACT_DO_NOT_TRACK=1 pactfoundation/pact-broker
330335
```
331336

332-
Alternatively, block `static.scarf.sh` at the network level (or disable image loading in your browser when viewing this README) to disable the README impression pixel.
337+
To opt out of the README impression pixel, block `static.scarf.sh` at the network level, or disable image loading in your browser when viewing this README.
333338

334339
For more information, see [docs.pact.io/telemetry](https://docs.pact.io/telemetry).
335340

pact_broker/entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/sh
22

3+
# Send a lightweight, anonymous analytics ping (version + platform) to help us
4+
# understand adoption of this image. Opt out with PACT_DO_NOT_TRACK or
5+
# SCARF_NO_ANALYTICS. See https://docs.pact.io/telemetry for details.
6+
if [ -z "${PACT_DO_NOT_TRACK:-}" ] && [ -z "${SCARF_NO_ANALYTICS:-}" ] \
7+
&& [ -n "${PACT_BROKER_DOCKER_VERSION:-}" ] && [ -n "${PACT_BROKER_DOCKER_PLATFORM:-}" ]; then
8+
wget -q -T 2 -t 1 -O /dev/null "https://d.pactflow.io/pact-broker-docker/${PACT_BROKER_DOCKER_VERSION}/${PACT_BROKER_DOCKER_PLATFORM}" >/dev/null 2>&1 &
9+
fi
10+
311
if [ "${PACT_BROKER_DATABASE_CLEAN_ENABLED}" = "true" ]; then
412
echo "Creating crontab with schedule ${PACT_BROKER_DATABASE_CLEAN_CRON_SCHEDULE} to clean database"
513
echo "${PACT_BROKER_DATABASE_CLEAN_CRON_SCHEDULE} /usr/local/bin/clean" >> /pact_broker/crontab

script/release-workflow/docker-build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ DOCKER_IMAGE_ORG_AND_NAME="${DOCKER_REPOSITORY:-pactfoundation}/pact-broker"
99
for arch in $ARCHES; do
1010
docker buildx build \
1111
--platform linux/$arch \
12+
--build-arg VERSION="${TAG:-dev}" \
1213
--output type=docker \
1314
--tag ${DOCKER_IMAGE_ORG_AND_NAME}:latest-${arch} \
1415
.

script/release-workflow/docker-push.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ set -euo >/dev/null
77
push() {
88
## These will use cached builds, so wont build every time.
99
docker buildx build --platform=linux/amd64,linux/arm64,linux/arm \
10+
--build-arg VERSION=${TAG} \
1011
--annotation "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
1112
--annotation "org.opencontainers.image.revision=$GITHUB_SHA" \
1213
--output=type=image,push=true \
1314
-t ${DOCKER_IMAGE_ORG_AND_NAME}:$1 .
1415
}
1516
push_ghcr() {
1617
docker buildx build --platform=linux/amd64,linux/arm64,linux/arm \
18+
--build-arg VERSION=${TAG} \
1719
--output=type=image,push=true \
1820
-t ghcr.io/$(echo $DOCKER_IMAGE_ORG_AND_NAME | sed 's/pactfoundation/pact-foundation/g'):$1 .
1921
}

0 commit comments

Comments
 (0)