Add dockerfile and a github action to publish docker image

This commit is contained in:
lconsuegra 2021-01-07 14:58:12 +01:00
parent adbca53201
commit 272ff8da17
2 changed files with 36 additions and 0 deletions

19
.github/workflows/docker-release.yml vendored Normal file
View File

@ -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

17
Dockerfile Normal file
View File

@ -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}" ]