Skip to content

Commit 3d20338

Browse files
committed
feat(shared/statsd-exporter): Build from source using Patchable
1 parent ec9bacb commit 3d20338

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

shared/statsd-exporter/Dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,30 @@ EOF
3636
COPY --from=golang-image /usr/local/go/ /usr/local/go/
3737
ENV PATH="/usr/local/go/bin:${PATH}"
3838

39+
COPY --chown=${STACKABLE_USER_UID}:0 shared/statsd-exporter/stackable/patches/patchable.toml /statsd_exporter/src/shared/statsd-exporter/stackable/patches/patchable.toml
40+
COPY --chown=${STACKABLE_USER_UID}:0 shared/statsd-exporter/stackable/patches/${PRODUCT_VERSION} /statsd_exporter/src/shared/statsd-exporter/stackable/patches/${PRODUCT_VERSION}
41+
3942
RUN --mount=type=cache,id=go-statsd-exporter,uid=${STACKABLE_USER_UID},target=/go_cache <<EOF
4043
export GOPATH=/go_cache
4144
go install "github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@v${CYCLONEDX_GOMOD_VERSION}"
4245

43-
curl "https://repo.stackable.tech/repository/packages/statsd_exporter/statsd_exporter-${PRODUCT_VERSION}.src.tar.gz" | tar -xzC .
4446
(
45-
cd "statsd_exporter-${PRODUCT_VERSION}" || exit
47+
cd "$(/stackable/patchable --images-repo-root=src checkout shared/statsd-exporter ${PRODUCT_VERSION})"
48+
49+
# Create snapshot of the source code including custom patches
50+
tar -czf /statsd_exporter/statsd-exporter-${PRODUCT_VERSION}-src.tar.gz .
4651

4752
# Unfortunately, we need to create a dummy Git repository to allow cyclonedx-gomod to determine the version of statsd_exporter
53+
rm .git
4854
git init
4955
git config user.email "fake.commiter@stackable.tech"
5056
git config user.name "Fake commiter"
5157
git commit --allow-empty --message "Fake commit, so that we can create a tag"
5258
git tag "v${PRODUCT_VERSION}"
53-
go build -o ../statsd_exporter
54-
$GOPATH/bin/cyclonedx-gomod app -json -output-version 1.5 -output ../statsd_exporter-${PRODUCT_VERSION}.cdx.json -packages -files
59+
go build -o /statsd_exporter/statsd_exporter
60+
$GOPATH/bin/cyclonedx-gomod app -json -output-version 1.5 -output /statsd_exporter/statsd_exporter-${PRODUCT_VERSION}.cdx.json -packages -files
5561
)
5662
rm -rf "statsd_exporter-${PRODUCT_VERSION}"
63+
# set correct groups
64+
chmod -R g=u /statsd_exporter/
5765
EOF

shared/statsd-exporter/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,21 @@ This is the Docker image that builds statsd_exporter.
55
This image does _not_ need to be built manually.
66
It will be built automatically if specified as a dependency in our `boil-config.toml` file.
77
Which will then be transformed to a dependency in a Docker `buildx bake` file.
8+
9+
## Updating
10+
11+
This image uses patchable for applying patch sets before building from source.
12+
Our mirror can be found here:
13+
14+
To update:
15+
16+
> [!CAUTION]
17+
> Check the changes since the last version, eg:
18+
> <https://github.com/prometheus/statsd_exporter/compare/v0.29.0...v0.30.0>
19+
20+
```shell
21+
STATSD_VERSION=0.29.0
22+
cargo patchable init version "shared/statsd-exporter" "$STATSD_VERSION" --base="v$STATSD_VERSION" --mirror
23+
```
24+
25+
Apply any necessary patches (see previous version's patch set).

0 commit comments

Comments
 (0)