dgl / ircd_exporter

Prometheus exporter for IRC server state
MIT License
8 stars 3 forks source link

Docker / Docker-Compose #3

Open Tob1as opened 1 year ago

Tob1as commented 1 year ago

Hi,
i create a Dockerfile and Docker-Compose example.

Here is the Dockerfile:

# docker build --no-cache --progress=plain --build-arg GOLANG_VERSION=1.21 -t local/ircd-exporter:latest -f Dockerfile .
ARG GOLANG_VERSION=1.21
FROM golang:${GOLANG_VERSION}-alpine as builder

#ENV GOPATH /go
ENV CGO_ENABLED 0
#ENV GO111MODULE on

RUN \
    apk add --no-cache git ; \
    git clone https://github.com/dgl/ircd_exporter.git ./ircd_exporter ; \
    cd ./ircd_exporter ; \
    go mod download ; \
    cd ./cmd/ircd_exporter/ ; \
    go build 

FROM scratch

ARG BUILD_DATE

LABEL org.opencontainers.image.title="ircd_exporter" \
    org.opencontainers.image.created="${BUILD_DATE}" \
    org.opencontainers.image.description="Prometheus exporter for IRC server state" \
    org.opencontainers.image.licenses="MIT" \
    org.opencontainers.image.source="https://github.com/dgl/ircd_exporter"

COPY --from=builder --chown=100:100 /go/ircd_exporter/cmd/ircd_exporter/ircd_exporter /usr/local/bin/ircd_exporter

USER 100:100
EXPOSE 9678/tcp
ENTRYPOINT ["ircd_exporter"]
CMD ["--help"]

I build with golang 1.21 and tested with ngircd and it works. (Unfortunately, it does not work completely with ergo-chat.)

Here is the docker-compose.yml file:

version: '2.4'
services:

  # https://github.com/dgl/ircd_exporter
  ircd-exporter:
    image: local/ircd-exporter:latest
    build:
      #context: ./
      dockerfile: Dockerfile
      #args:
      #  GOLANG_VERSION: 1.21
      #  BUILD_DATE: 2023-10-01
    container_name: ircd-exporter
    restart: unless-stopped
    #ports:
    #  - 127.0.0.1:9678:9678/tcp
    command:
      - "-irc.nick=promexp"
      #- "-irc.oper=admin"
      #- "-irc.oper-password="
      #- "-irc.password="
      - "-irc.server=ircd:6667"
      #- "-listen=:9678"
      - "-stats.command-usage"
      #- "-stats.ignore="
      - "-stats.local-only"
      #- "-stats.nicks="
      #- "-stats.timeout=9s"
    #depends_on:
    #  - ircd

Maybe it helps someone :wink:

dgl commented 1 year ago

Thanks, I'd happy take a PR adding the Dockerfile and push an image out for people, I just hadn't got around to it.