Skip to content

How to add scripts that rely on curl #49

@chrisbloemker

Description

@chrisbloemker

Hello,

I am curious what would be the best way to install packages like curl and jq for scripts like this:

- name: website_health
  script: curl -s -o /dev/null -w "%{http_code}" https://google.com
  timeout: 5

I know blackbox_exporter is more suited for this case but I am looking to do more advanced things like this such as curling an Elasticsearch endpoint and filter through json output for a value.

I have tried adding curl after the apk add statement where it installs bash but I receive the following error

------
 > [build-env 3/7] RUN go get -u github.com/prometheus/promu:
#9 6.835 package github.com/google/go-github/v25/github: cannot find package "github.com/google/go-github/v25/github" in any of:
#9 6.835 	/usr/local/go/src/github.com/google/go-github/v25/github (from $GOROOT)
#9 6.835 	/go/src/github.com/google/go-github/v25/github (from $GOPATH)
------
executor failed running [/bin/sh -c go get -u github.com/prometheus/promu]: exit code: 1

Here is my Dockerfile I am trying to build from:

FROM golang:1.14.1-alpine AS build-env

RUN apk add --update git gcc libc-dev
RUN go get -u github.com/prometheus/promu

RUN mkdir script_exporter
COPY .promu.yml script_exporter.go go.mod go.sum /go/script_exporter/

WORKDIR /go/script_exporter
RUN promu build

FROM alpine:3.11
LABEL upstream="https://github.com/adhocteam/script_exporter"
LABEL maintainer="james.kassemi@adhocteam.us"
RUN apk add --no-cache bash curl
COPY --from=build-env /go/script_exporter/script_exporter /bin/script-exporter
COPY script-exporter.yml /etc/script-exporter/config.yml

EXPOSE      9172
ENTRYPOINT  [ "/bin/script-exporter" ]
CMD ["-config.file=/etc/script-exporter/config.yml"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions