Skip to content

Commit

Permalink
Build and push docker images using Travis CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
wi1dcard committed Jan 8, 2020
1 parent b2e6bdc commit 960ec64
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: go

go:
- "1.13"
services:
- docker
env:
global:
- TAG=$TRAVIS_BRANCH

if: branch = master OR tag IS present

before_script:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- make before_build

script:
- make docker_build && make docker_push && make docker_manifest

notifications:
email:
on_success: never # default: change
on_failure: always # default: always
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ COMMIT = $(shell git rev-parse --short HEAD)
FULL_COMMIT = $(shell git rev-parse HEAD)
RELEASE_NOTES = $(shell git log ${LAST_TAG}..HEAD --oneline --decorate)
DATE = $(shell date +%Y-%m-%d)
DOCKER_REPO = wi1dcard/v2ray-exporter

export DOCKER_CLI_EXPERIMENTAL=enabled

lint:
golangci-lint run *.go
Expand All @@ -29,6 +32,17 @@ release: build
@ghr -u wi1dcard -b "${RELEASE_NOTES}" -c "${FULL_COMMIT}" "${TAG}" dist/

docker_build: build
docker build --build-arg ARCH=amd64 -t "wi1dcard/v2ray-exporter:${TAG}" .
docker build --build-arg ARCH=arm64 -t "wi1dcard/v2ray-exporter:${TAG}-arm64" .
docker build --build-arg ARCH=arm -t "wi1dcard/v2ray-exporter:${TAG}-arm" .
docker build --build-arg ARCH=amd64 -t "${DOCKER_REPO}:${TAG}-amd64" .
docker build --build-arg ARCH=arm64 -t "${DOCKER_REPO}:${TAG}-arm64" .
docker build --build-arg ARCH=arm -t "${DOCKER_REPO}:${TAG}-arm" .

docker_push: check_tag
docker push "${DOCKER_REPO}:${TAG}-amd64"
docker push "${DOCKER_REPO}:${TAG}-arm64"
docker push "${DOCKER_REPO}:${TAG}-arm"

docker_manifest: check_tag
docker manifest create --amend "${DOCKER_REPO}:${TAG}" "${DOCKER_REPO}:${TAG}-amd64" "${DOCKER_REPO}:${TAG}-arm64" "${DOCKER_REPO}:${TAG}-arm"
docker manifest annotate "${DOCKER_REPO}:${TAG}" "${DOCKER_REPO}:${TAG}-arm64" --os linux --arch arm64
docker manifest annotate "${DOCKER_REPO}:${TAG}" "${DOCKER_REPO}:${TAG}-arm" --os linux --arch arm
docker manifest push "${DOCKER_REPO}:${TAG}"

0 comments on commit 960ec64

Please sign in to comment.