Skip to content

Commit

Permalink
Dockerized CLI plugin (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac authored Sep 30, 2024
1 parent f71f437 commit 093d12f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 9 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_IMAGE_NAME: hasura/ndc-prometheus
DOCKER_CLI_IMAGE_NAME: hasura/ndc-prometheus-cli

jobs:
tests:
Expand Down Expand Up @@ -44,6 +45,21 @@ jobs:
push: true
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}
platforms: linux/amd64,linux/arm64

- name: Extract metadata (tags, labels) for the CLI
id: docker-metadata-cli
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_CLI_IMAGE_NAME }}

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.docker-metadata-cli.outputs.tags }}
labels: ${{ steps.docker-metadata-cli.outputs.labels }}
platforms: linux/amd64,linux/arm64

build-cli-binaries:
name: build the CLI binaries
Expand All @@ -53,8 +69,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"

- name: build the CLI
run: |
VERSION="$GITHUB_REF_NAME" make ci-build-configuration
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Format
run: diff -u <(echo -n) <(gofmt -d -s .)
- name: Vet
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=builder /app/ndc-prometheus /ndc-prometheus

ENV HASURA_CONFIGURATION_DIRECTORY=/etc/connector
ENV OTEL_SERVICE_NAME=ndc_prometheus

ENTRYPOINT ["/ndc-prometheus"]

Expand Down
18 changes: 18 additions & 0 deletions Dockerfile.cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# build context at repo root: docker build -f Dockerfile .
FROM golang:1.23 AS builder

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN make build-configuration

# stage 2: production image
FROM alpine:3.20

# Copy the binary to the production image from the builder stage.
COPY --from=builder /app/_output/ndc-prometheus /bin/ndc-prometheus-cli

WORKDIR /app

ENTRYPOINT ["/bin/ndc-prometheus-cli"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ clean:

.PHONY: build-configuration
build-configuration:
go build -o _output/ndc-prometheus ./configuration
CGO_ENABLED=0 go build -o _output/ndc-prometheus ./configuration

.PHONY: build-jsonschema
build-jsonschema:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ supportedEnvironmentVariables:
description: The connection URL to the Prometheus server
required: true
commands:
update: ndc-prometheus update
update:
type: Dockerized
dockerImage: ghcr.io/hasura/ndc-prometheus-cli:{{VERSION}}
commandArgs: ["update"]
cliPlugin:
name: ndc-prometheus
version: {{VERSION}}
type: Docker
dockerImage: ghcr.io/hasura/ndc-prometheus-cli:{{VERSION}}
dockerComposeWatch:
# copy config files into the existing container and restart it
- path: ./configuration.yaml
Expand Down

0 comments on commit 093d12f

Please sign in to comment.