Skip to content

Commit 8688cf2

Browse files
committed
New release process using docker, circleci and a centralized
building tool
1 parent 261aba6 commit 8688cf2

File tree

10 files changed

+136
-163
lines changed

10 files changed

+136
-163
lines changed

.dockerignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
data/
2-
prometheus
3-
promtool
2+
.build/
3+
.tarballs/
4+
5+
!.build/linux-amd64/

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ core
3131
benchmark.txt
3232
/data
3333
/.build
34+
/.release
35+
/.tarballs
3436

3537
.#*
3638
command-line-arguments.test
3739
*BACKUP*
3840
*LOCAL*
3941
*REMOTE*
42+
43+
!/circle.yml
44+
!/.travis.yml
45+
!/.promu.yml

.promu.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
go: 1.5.4
2+
repository:
3+
path: github.com/prometheus/prometheus
4+
build:
5+
binaries:
6+
- name: prometheus
7+
path: ./cmd/prometheus
8+
- name: promtool
9+
path: ./cmd/promtool
10+
flags: -tags netgo
11+
ldflags: |
12+
-X {{repoPath}}/version.Version={{.Version}}
13+
-X {{repoPath}}/version.Revision={{.Revision}}
14+
-X {{repoPath}}/version.Branch={{.Branch}}
15+
-X {{repoPath}}/version.BuildUser={{user}}@{{host}}
16+
-X {{repoPath}}/version.BuildDate={{date "20060102-15:04:05"}}
17+
tarball:
18+
files:
19+
- consoles
20+
- console_libraries
21+
- documentation/examples/prometheus.yml
22+
- LICENSE
23+
- NOTICE
24+
crossbuild:
25+
platforms:
26+
- linux/amd64
27+
- linux/386
28+
- darwin/amd64
29+
- darwin/386
30+
- windows/amd64
31+
- windows/386
32+
- freebsd/amd64
33+
- freebsd/386
34+
- openbsd/amd64
35+
- openbsd/386
36+
- netbsd/amd64
37+
- netbsd/386
38+
- dragonfly/amd64
39+
- linux/arm
40+
- linux/arm64
41+
- freebsd/arm
42+
- openbsd/arm
43+
- netbsd/arm
44+
- linux/ppc64
45+
- linux/ppc64le

Dockerfile

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
FROM sdurrheimer/alpine-glibc
1+
FROM prom/busybox:latest
22
MAINTAINER The Prometheus Authors <[email protected]>
33

4-
WORKDIR /gopath/src/github.com/prometheus/prometheus
5-
COPY . /gopath/src/github.com/prometheus/prometheus
6-
7-
RUN apk add --update -t build-deps tar openssl git make bash \
8-
&& source ./scripts/goenv.sh /go /gopath \
9-
&& make build \
10-
&& cp prometheus promtool /bin/ \
11-
&& mkdir -p /etc/prometheus \
12-
&& mv ./documentation/examples/prometheus.yml /etc/prometheus/prometheus.yml \
13-
&& mv ./console_libraries/ ./consoles/ /etc/prometheus/ \
14-
&& apk del --purge build-deps \
15-
&& rm -rf /go /gopath /var/cache/apk/*
4+
COPY prometheus /bin/prometheus
5+
COPY promtool /bin/promtool
6+
COPY documentation/examples/prometheus.yml /etc/prometheus/prometheus.yml
7+
COPY console_libraries/ /etc/prometheus/
8+
COPY consoles/ /etc/prometheus/
169

1710
EXPOSE 9090
1811
VOLUME [ "/prometheus" ]

Makefile

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
GO := GO15VENDOREXPERIMENT=1 go
1515
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
1616

17+
PREFIX ?= $(shell pwd)
18+
BIN_DIR ?= $(shell pwd)
19+
DOCKER_IMAGE_NAME ?= prometheus
20+
DOCKER_IMAGE_TAG ?= $(shell git rev-parse --abbrev-ref HEAD)
21+
1722
ifdef DEBUG
1823
bindata_flags = -debug
1924
endif
@@ -41,22 +46,27 @@ vet:
4146
@echo ">> vetting code"
4247
@$(GO) vet $(pkgs)
4348

44-
build:
49+
build: promu
4550
@echo ">> building binaries"
46-
@./scripts/build.sh
51+
@promu build --prefix $(PREFIX)
4752

48-
tarballs:
49-
@echo ">> building release tarballs"
50-
@./scripts/release_tarballs.sh
53+
tarball: promu
54+
@echo ">> building release tarball"
55+
@promu tarball --prefix $(PREFIX) $(BIN_DIR)
5156

5257
docker:
53-
@docker build -t prometheus:$(shell git rev-parse --short HEAD) .
58+
@echo ">> building docker image"
59+
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
5460

5561
assets:
5662
@echo ">> writing assets"
5763
@$(GO) get -u github.com/jteeuwen/go-bindata/...
5864
@go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/...
5965

66+
promu:
67+
@GOOS=$(shell uname -s | tr A-Z a-z) \
68+
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
69+
$(GO) get -u github.com/prometheus/promu
6070

61-
.PHONY: all style check_license format build test vet docker assets tarballs
6271

72+
.PHONY: all style check_license format build test vet assets tarball docker promu

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# Prometheus [![Build Status](https://travis-ci.org/prometheus/prometheus.svg)](https://travis-ci.org/prometheus/prometheus) [![Circle CI](https://circleci.com/gh/prometheus/prometheus/tree/master.svg?style=svg)](https://circleci.com/gh/prometheus/prometheus/tree/master)
1+
# Prometheus [![Build Status](https://travis-ci.org/prometheus/prometheus.svg)][travis]
2+
3+
[![CircleCI](https://circleci.com/gh/prometheus/prometheus/tree/master.svg?style=shield)][circleci]
4+
[![Docker Stars](https://img.shields.io/docker/stars/prom/prometheus.svg)][hub]
5+
[![Docker Pulls](https://img.shields.io/docker/pulls/prom/prometheus.svg)][hub]
6+
[![Image Size](https://img.shields.io/imagelayers/image-size/prom/prometheus/latest.svg)][imagelayers]
7+
[![Image Layers](https://img.shields.io/imagelayers/layers/prom/prometheus/latest.svg)][imagelayers]
28

39
Visit [prometheus.io](https://prometheus.io) for the full documentation,
410
examples and guides.
@@ -80,3 +86,9 @@ Refer to [CONTRIBUTING.md](CONTRIBUTING.md)
8086
## License
8187

8288
Apache License 2.0, see [LICENSE](LICENSE).
89+
90+
91+
[travis]: https://travis-ci.org/prometheus/prometheus
92+
[hub]: https://hub.docker.com/r/prom/prometheus/
93+
[circleci]: https://circleci.com/gh/prometheus/prometheus
94+
[imagelayers]: https://imagelayers.io/?images=prom/prometheus:latest

circle.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,54 @@
11
machine:
2+
environment:
3+
DOCKER_IMAGE_NAME: prom/prometheus
4+
DOCKER_TEST_IMAGE_NAME: prom/golang-builder:1.5.3-main
5+
REPO_PATH: github.com/prometheus/prometheus
6+
pre:
7+
- sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.1-circleci'
8+
- sudo chmod 0755 /usr/bin/docker
9+
- sudo curl -L 'https://github.com/aktau/github-release/releases/download/v0.6.2/linux-amd64-github-release.tar.bz2' | tar xvjf - --strip-components 3 -C $HOME/bin
210
services:
311
- docker
412

513
dependencies:
14+
pre:
15+
- go get -u github.com/prometheus/promu
16+
- docker info
617
override:
7-
- make docker
18+
- promu crossbuild
19+
- ln -s .build/linux-amd64/prometheus prometheus
20+
- ln -s .build/linux-amd64/promtool promtool
21+
- |
22+
if [ -n "$CIRCLE_TAG" ]; then
23+
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG
24+
else
25+
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME
26+
fi
27+
post:
28+
- mkdir $CIRCLE_ARTIFACTS/binaries/ && cp -a .build/* $CIRCLE_ARTIFACTS/binaries/
29+
- docker images
830

931
test:
1032
override:
11-
- /bin/true
33+
- docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T
34+
35+
deployment:
36+
hub_branch:
37+
branch: master
38+
owner: prometheus
39+
commands:
40+
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
41+
- docker push $DOCKER_IMAGE_NAME
42+
hub_tag:
43+
tag: /^[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
44+
owner: prometheus
45+
commands:
46+
- promu crossbuild tarballs
47+
- promu release .tarballs
48+
- mkdir $CIRCLE_ARTIFACTS/releases/ && cp -a .tarballs/* $CIRCLE_ARTIFACTS/releases/
49+
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
50+
- |
51+
if [[ "$CIRCLE_TAG" =~ ^[0-9]+(\.[0-9]+){2}$ ]]; then
52+
docker tag "$DOCKER_IMAGE_NAME:$CIRCLE_TAG" "$DOCKER_IMAGE_NAME:latest"
53+
fi
54+
- docker push $DOCKER_IMAGE_NAME

scripts/build.sh

Lines changed: 0 additions & 46 deletions
This file was deleted.

scripts/goenv.sh

Lines changed: 0 additions & 50 deletions
This file was deleted.

scripts/release_tarballs.sh

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)