From 3683b8fdca53c628f1b7c438e71aeb2cfb66d9f4 Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Wed, 23 Sep 2015 22:30:54 +0200 Subject: [PATCH 1/2] Use Travis to build packages and upload them to S3 To make this more convenient for travis, the image building is no longer a Makefile dependency. Instead, the following targets are added: * make images - build images from docker file * make push-images - push images to the docker hub * make pull-images - pull images from the docker hub The push requires the credentials for the tudorg account, but Travis has them, so you can (ab)use it to rebuild the images if we need to change something in the Dockerfiles. --- .travis.yml | 31 +++++++++++++++++++++++++++++++ Makefile | 34 ++++++++++++++++++++++++++-------- README.md | 11 ++++++++++- 3 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..2538f148828 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +sudo: required +services: + - docker + +language: go + +go: + - 1.5.1 + +before_install: + - docker login -e="$DOCKER_EMAIL" -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" + +script: + - make pull-images + # uncomment to build fresh images + # - make images + # - make push-images + - make deps + - make + +deploy: + provider: s3 + access_key_id: AKIAIAXUU3N2C6EHT5GQ + secret_access_key: + secure: VG6DjUxIf4A1Im2XEXNpzDYxCtQxFCdWs7loKmrXl3r6W/EGiBV0CaZ8f2qqh6sV/jRYegc3J8Qq0R6T4aVDoGznArxmLYOXa1stTuO5l5K0y79CYCypkv7XlYi0cUG9iHmTRi8X+Im4P1FZl8n8q1s8YhHguLIRvhvCGjHGYm/OqdM6RVAEMwjDNTT2SdAaILnmJWdjz6TVjHU9dwuses+0gQww2kYSyWm6c86TiDjwTLcLJWhh2QJXbUcaNeu646Y/imcjdQ0UZuxmz63cO7cdeOs2jejwuFGq0ABfZPtUF7Rm1k9e/HxCzGc5m5XYutnHm8+1gh8UMBojNR/kQkPcO8YpERIGy85ndEnmWxSKXWLF6aH23EtWVDGQrWue92eXrCwkrHqNrJFoB87f7xL/sSgf/u08nC6DCZhQE22RJrKaw9cw9lUqg6ExtVmAM5TKrt1KuVD2ehI+3Ml8GN6HCIZxSmLfze6nuYwaXTKC4gCYL+QQYhbPOvpyMH6Mumh4m7Z2EwXW/LGje/dMWYO/YFQ+TjUYnfElAMvAgKmMzmUP2aZcKHR6o1urftW16iYys8GRpbr3lG+Gnvzpl8qMA8Px8c8xXPgoRxJJzRnITBIJndx2LknpNN8VD4nbGPqXFirFG1kwVd87osa0Ogg2kxlwkxJqXyuZWjgIuGA= + bucket: beats-nightlies + local-dir: build/upload + acl: public_read + on: + repo: tsg/beats-packer + branch: travis_build diff --git a/Makefile b/Makefile index 0ecb211a8c5..14c1988b2be 100644 --- a/Makefile +++ b/Makefile @@ -8,19 +8,19 @@ all: packetbeat/deb packetbeat/rpm packetbeat/darwin packetbeat/win packetbeat/b .PHONY: packetbeat topbeat -packetbeat topbeat: xgo-image build +packetbeat topbeat: build cd build && xgo -image=tudorg/beats-builder \ -before-build=../xgo-scripts/$@_before_build.sh \ -branch $(RELEASE) \ github.com/elastic/$@ .PHONY: packetbeat-linux topbeat-linux -packetbeat-linux: xgo-image build +packetbeat-linux: build cd build && xgo -image=tudorg/beats-builder-deb6 \ -before-build=../xgo-scripts/packetbeat_before_build.sh \ -branch $(RELEASE) \ github.com/elastic/packetbeat -topbeat-linux: xgo-image build +topbeat-linux: build cd build && xgo -image=tudorg/beats-builder-deb6 \ -before-build=../xgo-scripts/topbeat_before_build.sh \ -branch $(RELEASE) \ @@ -34,17 +34,17 @@ topbeat-linux: xgo-image build ARCH=386 RELEASE=$(RELEASE) BEAT=$(@D) BUILDID=$(BUILDID) ./platforms/centos/build.sh ARCH=amd64 RELEASE=$(RELEASE) BEAT=$(@D) BUILDID=$(BUILDID) ./platforms/centos/build.sh -%/darwin: % fpm-image +%/darwin: % ARCH=amd64 RELEASE=$(RELEASE) BEAT=$(@D) BUILDID=$(BUILDID) ./platforms/darwin/build.sh -%/win: % fpm-image +%/win: % ARCH=amd64 RELEASE=$(RELEASE) BEAT=$(@D) BUILDID=$(BUILDID) ./platforms/windows/build.sh -%/bin: %-linux fpm-image +%/bin: %-linux ARCH=386 RELEASE=$(RELEASE) BEAT=$(@D) BUILDID=$(BUILDID) ./platforms/binary/build.sh ARCH=amd64 RELEASE=$(RELEASE) BEAT=$(@D) BUILDID=$(BUILDID) ./platforms/binary/build.sh -.PHONY: deps xgo-image +.PHONY: deps deps: go get github.com/tsg/xgo go get github.com/tsg/gotpl @@ -62,7 +62,7 @@ fpm-image: go-daemon-image: docker build --rm=true -t tudorg/go-daemon docker/go-daemon/ -build/god-linux-386 build/god-linux-amd64: go-daemon-image +build/god-linux-386 build/god-linux-amd64: docker run -v $(shell pwd)/build:/build tudorg/go-daemon build: @@ -82,6 +82,24 @@ run-interactive: docker run -t -i -v $(shell pwd)/build:/build \ -v $(shell pwd)/xgo-scripts/:/scripts \ --entrypoint=bash tudorg/beats-builder-deb6 + +.PHONY: images +images: xgo-image fpm-image go-daemon-image + +.PHONY: push-images +push-images: + docker push tudorg/beats-builder + docker push tudorg/beats-builder-deb6 + docker push tudorg/fpm + docker push tudorg/go-daemon + +.PHONY: pull-images +pull-images: + docker pull tudorg/beats-builder + docker pull tudorg/beats-builder-deb6 + docker pull tudorg/fpm + docker pull tudorg/go-daemon + .PHONY: clean clean: rm -rf build/ || true diff --git a/README.md b/README.md index 08efc191ed3..71e319b4b6d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,16 @@ Tools, scripts and docker images for cross-compiling and packaging the Elastic ## Prepare -You need Go and docker installed. Prepare the rest with: +You need Go and docker installed. This project uses several docker files, you +can either build them with: + + make images + +Or pull them from the Docker registry with: + + make pull-images + +Prepare the rest with: make deps From 458a409ab67791293a13ec7bfb9c36f59b2f0ce3 Mon Sep 17 00:00:00 2001 From: Tudor Golubenco Date: Thu, 24 Sep 2015 13:14:59 +0200 Subject: [PATCH 2/2] Only upload from the master branch, and not from forks --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2538f148828..7fb8a8af222 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,5 +27,5 @@ deploy: local-dir: build/upload acl: public_read on: - repo: tsg/beats-packer - branch: travis_build + repo: elastic/beats-packer + branch: master