Skip to content

Commit

Permalink
New release process using docker, circleci and a centralized
Browse files Browse the repository at this point in the history
building tool
  • Loading branch information
sdurrheimer committed Apr 18, 2016
1 parent 261aba6 commit 8688cf2
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 163 deletions.
6 changes: 4 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
data/
prometheus
promtool
.build/
.tarballs/

!.build/linux-amd64/
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ core
benchmark.txt
/data
/.build
/.release
/.tarballs

.#*
command-line-arguments.test
*BACKUP*
*LOCAL*
*REMOTE*

!/circle.yml
!/.travis.yml
!/.promu.yml
45 changes: 45 additions & 0 deletions .promu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
go: 1.5.4
repository:
path: github.com/prometheus/prometheus
build:
binaries:
- name: prometheus
path: ./cmd/prometheus
- name: promtool
path: ./cmd/promtool
flags: -tags netgo
ldflags: |
-X {{repoPath}}/version.Version={{.Version}}
-X {{repoPath}}/version.Revision={{.Revision}}
-X {{repoPath}}/version.Branch={{.Branch}}
-X {{repoPath}}/version.BuildUser={{user}}@{{host}}
-X {{repoPath}}/version.BuildDate={{date "20060102-15:04:05"}}
tarball:
files:
- consoles
- console_libraries
- documentation/examples/prometheus.yml
- LICENSE
- NOTICE
crossbuild:
platforms:
- linux/amd64
- linux/386
- darwin/amd64
- darwin/386
- windows/amd64
- windows/386
- freebsd/amd64
- freebsd/386
- openbsd/amd64
- openbsd/386
- netbsd/amd64
- netbsd/386
- dragonfly/amd64
- linux/arm
- linux/arm64
- freebsd/arm
- openbsd/arm
- netbsd/arm
- linux/ppc64
- linux/ppc64le
19 changes: 6 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
FROM sdurrheimer/alpine-glibc
FROM prom/busybox:latest
MAINTAINER The Prometheus Authors <prometheus-developers@googlegroups.com>

WORKDIR /gopath/src/github.com/prometheus/prometheus
COPY . /gopath/src/github.com/prometheus/prometheus

RUN apk add --update -t build-deps tar openssl git make bash \
&& source ./scripts/goenv.sh /go /gopath \
&& make build \
&& cp prometheus promtool /bin/ \
&& mkdir -p /etc/prometheus \
&& mv ./documentation/examples/prometheus.yml /etc/prometheus/prometheus.yml \
&& mv ./console_libraries/ ./consoles/ /etc/prometheus/ \
&& apk del --purge build-deps \
&& rm -rf /go /gopath /var/cache/apk/*
COPY prometheus /bin/prometheus
COPY promtool /bin/promtool
COPY documentation/examples/prometheus.yml /etc/prometheus/prometheus.yml
COPY console_libraries/ /etc/prometheus/
COPY consoles/ /etc/prometheus/

EXPOSE 9090
VOLUME [ "/prometheus" ]
Expand Down
24 changes: 17 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
GO := GO15VENDOREXPERIMENT=1 go
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)

PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= prometheus
DOCKER_IMAGE_TAG ?= $(shell git rev-parse --abbrev-ref HEAD)

ifdef DEBUG
bindata_flags = -debug
endif
Expand Down Expand Up @@ -41,22 +46,27 @@ vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)

build:
build: promu
@echo ">> building binaries"
@./scripts/build.sh
@promu build --prefix $(PREFIX)

tarballs:
@echo ">> building release tarballs"
@./scripts/release_tarballs.sh
tarball: promu
@echo ">> building release tarball"
@promu tarball --prefix $(PREFIX) $(BIN_DIR)

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

assets:
@echo ">> writing assets"
@$(GO) get -u github.com/jteeuwen/go-bindata/...
@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/...

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

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

.PHONY: all style check_license format build test vet assets tarball docker promu
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# 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)
# Prometheus [![Build Status](https://travis-ci.org/prometheus/prometheus.svg)][travis]

[![CircleCI](https://circleci.com/gh/prometheus/prometheus/tree/master.svg?style=shield)][circleci]
[![Docker Stars](https://img.shields.io/docker/stars/prom/prometheus.svg)][hub]
[![Docker Pulls](https://img.shields.io/docker/pulls/prom/prometheus.svg)][hub]
[![Image Size](https://img.shields.io/imagelayers/image-size/prom/prometheus/latest.svg)][imagelayers]
[![Image Layers](https://img.shields.io/imagelayers/layers/prom/prometheus/latest.svg)][imagelayers]

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

Apache License 2.0, see [LICENSE](LICENSE).


[travis]: https://travis-ci.org/prometheus/prometheus
[hub]: https://hub.docker.com/r/prom/prometheus/
[circleci]: https://circleci.com/gh/prometheus/prometheus
[imagelayers]: https://imagelayers.io/?images=prom/prometheus:latest
47 changes: 45 additions & 2 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,54 @@
machine:
environment:
DOCKER_IMAGE_NAME: prom/prometheus
DOCKER_TEST_IMAGE_NAME: prom/golang-builder:1.5.3-main
REPO_PATH: github.com/prometheus/prometheus
pre:
- sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.1-circleci'
- sudo chmod 0755 /usr/bin/docker
- 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
services:
- docker

dependencies:
pre:
- go get -u github.com/prometheus/promu
- docker info
override:
- make docker
- promu crossbuild
- ln -s .build/linux-amd64/prometheus prometheus
- ln -s .build/linux-amd64/promtool promtool
- |
if [ -n "$CIRCLE_TAG" ]; then
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG
else
make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME
fi
post:
- mkdir $CIRCLE_ARTIFACTS/binaries/ && cp -a .build/* $CIRCLE_ARTIFACTS/binaries/
- docker images

test:
override:
- /bin/true
- docker run --rm -t -v "$(pwd):/app" "${DOCKER_TEST_IMAGE_NAME}" -i "${REPO_PATH}" -T

deployment:
hub_branch:
branch: master
owner: prometheus
commands:
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- docker push $DOCKER_IMAGE_NAME
hub_tag:
tag: /^[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
owner: prometheus
commands:
- promu crossbuild tarballs
- promu release .tarballs
- mkdir $CIRCLE_ARTIFACTS/releases/ && cp -a .tarballs/* $CIRCLE_ARTIFACTS/releases/
- docker login -e $DOCKER_EMAIL -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- |
if [[ "$CIRCLE_TAG" =~ ^[0-9]+(\.[0-9]+){2}$ ]]; then
docker tag "$DOCKER_IMAGE_NAME:$CIRCLE_TAG" "$DOCKER_IMAGE_NAME:latest"
fi
- docker push $DOCKER_IMAGE_NAME
46 changes: 0 additions & 46 deletions scripts/build.sh

This file was deleted.

50 changes: 0 additions & 50 deletions scripts/goenv.sh

This file was deleted.

42 changes: 0 additions & 42 deletions scripts/release_tarballs.sh

This file was deleted.

0 comments on commit 8688cf2

Please sign in to comment.