From 272ff8da172fd26384837f9212d94c35b4269957 Mon Sep 17 00:00:00 2001 From: lconsuegra Date: Thu, 7 Jan 2021 14:58:12 +0100 Subject: [PATCH] Add dockerfile and a github action to publish docker image --- .github/workflows/docker-release.yml | 19 +++++++++++++++++++ Dockerfile | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/docker-release.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 0000000..d5faad9 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,19 @@ +name: Publish Docker image +on: + release: + types: [published] +jobs: + push_to_registry: + name: Push Docker image to GitHub Packages + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + - name: Push to GitHub Packages + uses: docker/build-push-action@v1 + with: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: ghcr.io + repository: camptocamp/cups_exporter + tag_with_ref: true diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8c5b87a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM golang:1.13 as builder + +WORKDIR /build +ADD . /build +RUN go build -o cups_exporter main.go + +FROM golang:1.13 + +LABEL maintainer="lenny.consuegra@camptocamp.com" + +ENV CUPS_URI "https://localhost:631" + +COPY --from=builder /build/cups_exporter /bin/cups_exporter + +EXPOSE 9329 + +CMD [ "/bin/sh", "-c", "/bin/cups_exporter -cups.uri ${CUPS_URI}" ]