Skip to content

Commit

Permalink
Merge pull request #358 from hligit/build-arm64-docker-image
Browse files Browse the repository at this point in the history
Build and publish Docker images for arm64
  • Loading branch information
hligit committed Dec 2, 2020
2 parents 1ecce56 + 275840a commit 366d57a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
35 changes: 29 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
sudo: required

language: go

services:
Expand All @@ -8,8 +6,33 @@ services:
go:
- "1.13.6" # Keep in sync with Makefile and README.md

os:
- linux
arch:
- amd64
- arm64


dist: bionic
os: linux

jobs:
include:
- os: linux
arch: amd64
- os: linux
arch: arm64
- stage: Push Docker manifest
env:
- DOCKER_CLI_EXPERIMENTAL=enabled
script:
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- sudo add-apt-repository "deb [arch=$TRAVIS_CPU_ARCH] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
- if [ "$TRAVIS_OS_NAME" == "linux" -a ! -z "$TRAVIS_TAG" ]; then
echo "Executing release-manifest on tag build $TRAVIS_TAG";
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
make release-manifest;
fi

before_install:
- go get -v github.com/mattn/goveralls
Expand All @@ -25,10 +48,10 @@ script:
- make bench-race

after_success:
- if [ "$TRAVIS_OS_NAME" == "linux" -a ! -z "$TRAVIS_TAG" ]; then
- if [ "$TRAVIS_BUILD_STAGE_NAME" == "test" -a "$TRAVIS_OS_NAME" == "linux" -a ! -z "$TRAVIS_TAG" ]; then
echo "Executing release on tag build $TRAVIS_TAG";
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD";
ARCH=linux make release;
ARCH=linux CPU_ARCH="$TRAVIS_CPU_ARCH" make release;
else
echo "Not executing release on non-tag build";
fi
Expand Down
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ GIT_HASH ?= $$(git rev-parse --short HEAD)
GOBUILD_VERSION_ARGS := -ldflags "-s -X $(VERSION_VAR)=$(REPO_VERSION) -X $(GIT_VAR)=$(GIT_HASH) -X $(BUILD_DATE_VAR)=$(BUILD_DATE)"
GOBUILD_VERSION_ARGS_WITH_SYMS := -ldflags "-X $(VERSION_VAR)=$(REPO_VERSION) -X $(GIT_VAR)=$(GIT_HASH) -X $(BUILD_DATE_VAR)=$(BUILD_DATE)"
BINARY_NAME := gostatsd
IMAGE_NAME := atlassianlabs/$(BINARY_NAME)
CPU_ARCH ?= amd64
MANIFEST_NAME := atlassianlabs/$(BINARY_NAME)
IMAGE_NAME := $(MANIFEST_NAME)-$(CPU_ARCH)
ARCH ?= $$(uname -s | tr A-Z a-z)
GOVERSION := 1.13.6 # Keep in sync with .travis.yml and README.md
GP := /gopath
Expand Down Expand Up @@ -160,6 +162,17 @@ release-symbols: docker-symbols

release: release-normal release-race release-symbols

release-manifest:
for tag in latest $(REPO_VERSION) $(GIT_HASH)-race $(REPO_VERSION)-race $(REPO_VERSION)-syms; do \
for arch in amd64 arm64; do \
docker pull $(MANIFEST_NAME)-$$arch:$$tag; \
done; \
docker manifest create $(MANIFEST_NAME):$$tag --amend \
$(MANIFEST_NAME)-amd64:$$tag \
$(MANIFEST_NAME)-arm64:$$tag; \
docker manifest push $(MANIFEST_NAME):$$tag; \
done

run: build
./build/bin/$(ARCH)/$(BINARY_NAME) --backends=stdout --verbose --flush-interval=2s

Expand Down

0 comments on commit 366d57a

Please sign in to comment.