Skip to content

Commit 93a1e59

Browse files
authored
Smaller docker images and go.mod support (#26)
* Smaller docker images and go.mod support * Move command to top level directory
1 parent cfc96e4 commit 93a1e59

File tree

10 files changed

+414
-5
lines changed

10 files changed

+414
-5
lines changed

.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Dockerfile
2+
Dockerfile.testing
3+
prometheus-bigquery-exporter
4+
README.md
5+
**/*_test.go

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/prometheus-bigquery-exporter

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: go
22

33
go:
4-
- '1.12'
4+
- '1.14'
55

66
# Unconditionally place the repo at GOPATH/src/${go_import_path} to support
77
# forks.
@@ -13,5 +13,6 @@ before_install:
1313

1414
script:
1515
# Run query "unit tests".
16+
- make
1617
- go test -short -v ./... -cover=1 -coverprofile=_c.cov
1718
- $GOPATH/bin/goveralls -service=travis-ci -coverprofile=_c.cov

Dockerfile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
FROM golang:1.12
1+
FROM quay.io/prometheus/golang-builder:1.14.2-main as builder
2+
23
ADD . /go/src/github.com/m-lab/prometheus-bigquery-exporter
3-
RUN go get -v github.com/m-lab/prometheus-bigquery-exporter/cmd/bigquery_exporter
4-
ENTRYPOINT ["/go/bin/bigquery_exporter"]
4+
WORKDIR /go/src/github.com/m-lab/prometheus-bigquery-exporter
5+
6+
RUN make
7+
8+
FROM quay.io/prometheus/busybox:glibc
9+
10+
COPY --from=builder /go/bin/prometheus-bigquery-exporter /bin/prometheus-bigquery-exporter
11+
12+
EXPOSE 9348
13+
14+
ENTRYPOINT [ "/bin/prometheus-bigquery-exporter" ]

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
GO := go
2+
DOCKER_IMAGE_NAME ?= prometheus-bigquery-exporter
3+
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
4+
5+
6+
all: vet build
7+
8+
vet:
9+
@echo ">> vetting code"
10+
@$(GO) vet $(pkgs)
11+
12+
build:
13+
@$(GO) get -t .
14+
15+
docker:
16+
@echo ">> building docker image"
17+
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
18+
19+
.PHONY: all build docker

go.mod

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module github.com/m-lab/prometheus-bigquery-exporter
2+
3+
go 1.14
4+
5+
require (
6+
cloud.google.com/go/bigquery v1.3.0
7+
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect
8+
github.com/golang/protobuf v1.4.1 // indirect
9+
github.com/google/go-github/v25 v25.1.3 // indirect
10+
github.com/googleapis/google-cloud-go-testing v0.0.0-20191008195207-8e1d251e947d
11+
github.com/m-lab/go v1.4.0
12+
github.com/pkg/errors v0.9.1 // indirect
13+
github.com/prometheus/client_golang v1.6.0
14+
github.com/prometheus/common v0.10.0 // indirect
15+
github.com/prometheus/promu v0.5.0 // indirect
16+
github.com/spf13/afero v1.2.2
17+
golang.org/x/net v0.0.0-20200513185701-a91f0712d120
18+
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
19+
golang.org/x/sys v0.0.0-20200513112337-417ce2331b5c // indirect
20+
google.golang.org/api v0.15.0
21+
google.golang.org/appengine v1.6.6 // indirect
22+
gopkg.in/yaml.v2 v2.3.0 // indirect
23+
)

go.sum

Lines changed: 350 additions & 0 deletions
Large diffs are not rendered by default.
File renamed without changes.
File renamed without changes.

query/bigquery_runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"strings"
1111

1212
"cloud.google.com/go/bigquery"
13-
"github.com/GoogleCloudPlatform/google-cloud-go-testing/bigquery/bqiface"
13+
"github.com/googleapis/google-cloud-go-testing/bigquery/bqiface"
1414
"github.com/m-lab/prometheus-bigquery-exporter/sql"
1515
"google.golang.org/api/iterator"
1616
)

0 commit comments

Comments
 (0)