Skip to content

Commit 054d825

Browse files
committed
Vendor all dependencies, add docker build to makefile.
Vendor and store all dependencies. This allows us to have a makefile which builds to a minimized docker image.
1 parent 976a502 commit 054d825

File tree

121 files changed

+26936
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+26936
-263
lines changed

Dockerfile

-4
This file was deleted.

Makefile

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
# Copyright 2015 The Prometheus Authors
2-
# Licensed under the Apache License, Version 2.0 (the "License");
3-
# you may not use this file except in compliance with the License.
4-
# You may obtain a copy of the License at
5-
#
6-
# http://www.apache.org/licenses/LICENSE-2.0
7-
#
8-
# Unless required by applicable law or agreed to in writing, software
9-
# distributed under the License is distributed on an "AS IS" BASIS,
10-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11-
# See the License for the specific language governing permissions and
12-
# limitations under the License.
131

14-
VERSION := 0.1.0
15-
TARGET := postgres_exporter
2+
# Simple go build
3+
postgres_exporter: postgres_exporter.go
4+
go build -o postgres_exporter .
165

17-
include Makefile.COMMON
6+
# Do a self-contained docker build - we pull the official upstream container,
7+
# then template out a dockerfile which builds the real image.
8+
docker:
9+
docker run -v $(shell pwd):/go/src/github.com/wrouesnel/postgres_exporter \
10+
golang:1.6-wheezy \
11+
/go/src/github.com/wrouesnel/postgres_exporter/docker-build.bsh /postgres_exporter /go/src/github.com/wrouesnel/postgres_exporter | \
12+
docker import --change "EXPOSE 9113" \
13+
--change 'ENTRYPOINT [ "/postgres_exporter" ]' \
14+
- wrouesnel/postgres_exporter
15+
16+
.PHONY: docker

Makefile.COMMON

-121
This file was deleted.

README.md

+23-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,29 @@
33
Prometheus exporter for PostgresSQL server metrics.
44
Supported Postgres versions: 9.1 and up.
55

6+
## Quick Start
7+
This package is available for Docker:
8+
```
9+
docker run -e DATA_SOURCE_NAME="login:password@(hostname:port)/dbname" -p 9113:9113 wrouesnel/postgres_exporter
10+
```
11+
612
## Building and running
13+
The default make file behavior is to build the binary:
14+
```
15+
make
16+
export DATA_SOURCE_NAME="login:password@(hostname:port)/dbname"
17+
./postgres_exporter <flags>
18+
```
19+
20+
To build the dockerfile, run `make docker`.
21+
22+
This will build the docker image as `wrouesnel/postgres_exporter:latest`. This
23+
is a minimal docker image containing *just* postgres_exporter. By default no SSL
24+
certificates are included, if you need to use SSL you should either bind-mount
25+
`/etc/ssl/certs/ca-certificates.crt` or derive a new image containing them.
726

8-
make
9-
export DATA_SOURCE_NAME="login:password@(hostname:port)/dbname"
10-
./postgres_exporter <flags>
27+
### Vendoring
28+
Package vendoring is handled with [`govendor`](https://github.com/kardianos/govendor)
1129

1230
### Flags
1331

@@ -34,5 +52,5 @@ for l in StringIO(x):
3452
column, ctype, description = l.split('\t')
3553
print """"{0}" : {{ prometheus.CounterValue, prometheus.NewDesc("pg_stat_database_{0}", "{2}", nil, nil) }}, """.format(column.strip(), ctype, description.strip())
3654
```
37-
Adjust the value of the resultant prometheus value type appropriately. This helps build
38-
rich self-documenting metrics for the exporter.
55+
Adjust the value of the resultant prometheus value type appropriately. This
56+
helps build rich self-documenting metrics for the exporter.

docker-build.bsh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
cd $2
3+
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o $1 . 1>&2
4+
tar -cf - $1

postgres_exporter

-9.04 MB
Binary file not shown.

0 commit comments

Comments
 (0)