diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6d2ba94 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +README.md +LICENSE +Dockerfile \ No newline at end of file diff --git a/.gitignore b/.gitignore index 98c98f4..b0057a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ azure_sql_exporter dist/ +config/ config.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9b96e09 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM alpine:latest as certificates +RUN apk update && apk add --no-cache ca-certificates && update-ca-certificates + + +FROM golang:1.12 as builder +ADD . /go/src/github.com/iamseth/azure_sql_exporter +WORKDIR /go/src/github.com/iamseth/azure_sql_exporter +RUN CGO_ENABLED=0 go build -ldflags "-X main.Version=$(cat VERSION)" + +FROM scratch + +# Copy certs from alpine as they don't exist from scratch +COPY --from=certificates /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /go/src/github.com/iamseth/azure_sql_exporter/azure_sql_exporter /app/ + +WORKDIR /app +ENTRYPOINT ["/app/azure_sql_exporter"] diff --git a/Makefile b/Makefile index 96ed227..b86f8da 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION := 0.1.0 +VERSION := 0.1.1 LDFLAGS := -X main.Version=$(VERSION) GOFLAGS := -ldflags "$(LDFLAGS)" @@ -26,4 +26,4 @@ format: .PHONY: docker docker: - docker run --rm -v "$$PWD":/go/src/github.com/iamseth/azure_sql_exporter -w /go/src/github.com/iamseth/azure_sql_exporter golang:1.6 bash -c make + docker build -t benclapp/azure_sql_exporter:$(VERSION) -t benclapp/azure_sql_exporter:latest . diff --git a/README.md b/README.md index c19a7d3..0d522c9 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,11 @@ databases: ## Binary releases Pre-compiled versions may be found in the [release section](https://github.com/iamseth/azure_sql_exporter/releases). + +## Docker + +A Dockerfile is provided, or images are available on [Docker Hub](https://hub.docker.com/r/benclapp/azure_sql_exporter/). For example: + +```bash +docker run -d -p 9139:9139 -v ./config.yaml:/config/config.yaml benclapp/azure_sql_exporter:latest -config.file /config/config.yaml +``` \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6da28dd --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.1 \ No newline at end of file