Skip to content

Commit 47e6b9e

Browse files
committed
Add jsonnet image
1 parent fd3395f commit 47e6b9e

File tree

6 files changed

+128
-0
lines changed

6 files changed

+128
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ jobs:
6060
hadolint: 'hadolint/**'
6161
hashicorp/terraform: 'hashicorp/terraform/**'
6262
jfrog/jfrog-cli: 'jfrog/jfrog-cli/**'
63+
jsonnet: 'jsonnet/**'
6364
ldap-utils: 'ldap-utils/**'
6465
markdownlint: 'markdownlint/**'
6566
meshcmd: 'meshcmd/**'

jsonnet/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
README.md
2+
test/

jsonnet/Containerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# syntax=docker/dockerfile:1
2+
# Arguments used in FROM need to be defined before the first build stage
3+
ARG BUILD_IMAGE=docker.io/polymathrobotics/golang:1.24-noble
4+
ARG BASE_IMAGE=docker.io/ubuntu:noble-20250529
5+
# hadolint ignore=DL3006
6+
FROM $BASE_IMAGE AS base
7+
8+
ARG JSONNET_URL_AMD64
9+
ARG JSONNET_SHA256_AMD64
10+
ARG JSONNET_URL_ARM64
11+
ARG JSONNET_SHA256_ARM64
12+
13+
FROM base AS download
14+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
15+
RUN <<EOF
16+
apt-get update
17+
apt-get install -y --no-install-recommends \
18+
ca-certificates \
19+
curl
20+
mkdir -p /tmp/jsonnet
21+
dpkgArch="$(dpkg --print-architecture)"
22+
case "${dpkgArch##*-}" in \
23+
amd64) \
24+
JSONNET_URL="${JSONNET_URL_AMD64}" \
25+
JSONNET_SHA256="${JSONNET_SHA256_AMD64}" \
26+
;; \
27+
arm64) \
28+
JSONNET_URL="${JSONNET_URL_ARM64}" \
29+
JSONNET_SHA256="${JSONNET_SHA256_ARM64}" \
30+
;; \
31+
*) echo "unsupported architecture"; exit 1 ;; \
32+
esac
33+
curl -fsSL -o /tmp/jsonnet.tar.gz "${JSONNET_URL}"
34+
echo "${JSONNET_SHA256} /tmp/jsonnet.tar.gz" | sha256sum -c -
35+
tar xvf /tmp/jsonnet.tar.gz -C /tmp/jsonnet
36+
EOF
37+
38+
FROM ${BUILD_IMAGE} AS build
39+
40+
RUN <<EOF
41+
go install github.com/monitoring-mixins/mixtool/cmd/mixtool@main
42+
EOF
43+
44+
FROM base
45+
46+
COPY --chmod=755 --from=download /tmp/jsonnet/jsonnet /usr/local/bin/jsonnet
47+
COPY --chmod=755 --from=download /tmp/jsonnet/jsonnetfmt /usr/local/bin/jsonnetfmt
48+
COPY --chmod=755 --from=download /tmp/jsonnet/jsonnet-lint /usr/local/bin/jsonnet-lint
49+
COPY --chmod=755 --from=download /tmp/jsonnet/jsonnet-deps /usr/local/bin/jsonnet-deps
50+
COPY --chmod=755 --from=build /go/bin/mixtool /usr/local/bin/mixtool
51+
52+
USER ubuntu

jsonnet/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# jsonnet
2+
3+
Jsonnet tools.
4+
5+
Jsonnet is a superset of JSON with added features like:
6+
- Variables
7+
- Functions
8+
- Conditionals
9+
- Imports
10+
- Object composition
11+
- Macros
12+
13+
## Included Tools
14+
15+
`jsonnet` - Jsonnet CLI interpreter
16+
`jsonnetfmt` - Formatter for Jsonnet files
17+
`jsonnet-lint` - Syntax and style checker for Jsonnet code.
18+
`jsonnet-deps` - Produces a dependency graph of Jsonnet file imports
19+
`mixtool` - Renders Prometheus monitoring mixins

jsonnet/docker-bake.hcl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
variable "TAG_PREFIX" {
2+
default = "docker.io/polymathrobotics/jsonnet"
3+
}
4+
5+
variable "VERSION" {
6+
default = "0.21.0"
7+
}
8+
9+
# There's no darwin-based Docker, so if we're running on macOS, change the platform to linux
10+
variable "LOCAL_PLATFORM" {
11+
default = regex_replace("${BAKE_LOCAL_PLATFORM}", "^(darwin)", "linux")
12+
}
13+
14+
target "_common" {
15+
dockerfile = "Containerfile"
16+
args = {
17+
JSONNET_URL_AMD64 = "https://github.com/google/go-jsonnet/releases/download/v0.21.0/go-jsonnet_Linux_x86_64.tar.gz"
18+
JSONNET_SHA256_AMD64 = "ad3181fde77726b02d17eb4e72687020bf2cb35b9336cdeaaca4783c7ff104f7"
19+
JSONNET_URL_ARM64 = "https://github.com/google/go-jsonnet/releases/download/v0.21.0/go-jsonnet_Linux_arm64.tar.gz"
20+
JSONNET_SHA256_ARM64 = "4a263da605dbe2edb99529f495266211062fac476789f2119408bc223338f1d6"
21+
}
22+
tags = [
23+
"${TAG_PREFIX}:${VERSION}",
24+
"${TAG_PREFIX}:latest",
25+
]
26+
labels = {
27+
"org.opencontainers.image.source" = "https://github.com/polymathrobotics/oci"
28+
"org.opencontainers.image.licenses" = "Apache-2.0"
29+
"org.opencontainers.image.description" = "Jsonnet utilities for Prometheus."
30+
"org.opencontainers.image.title" = "${TAG_PREFIX}"
31+
"org.opencontainers.image.created" = "${timestamp()}"
32+
}
33+
}
34+
35+
target "local" {
36+
inherits = ["_common"]
37+
platforms = ["${LOCAL_PLATFORM}"]
38+
}
39+
40+
target "default" {
41+
inherits = ["_common"]
42+
platforms = ["linux/amd64", "linux/arm64/v8"]
43+
}

jsonnet/test/controls/jsonnet.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
%w(
2+
jsonnet
3+
jsonnet-deps
4+
jsonnet-lint
5+
jsonnetfmt
6+
mixtool
7+
).each do |binary|
8+
describe command(binary) do
9+
it { should exist }
10+
end
11+
end

0 commit comments

Comments
 (0)