From a8a3d2562e14b45a95831fbe212658d50d66bbbc Mon Sep 17 00:00:00 2001 From: Lan Tian Date: Tue, 8 Jan 2019 14:29:07 +0800 Subject: [PATCH] Try add travis CI --- .travis.yml | 52 +++++++++++++++++++++++++++++++++++++++++++++ frontend/Dockerfile | 6 ++++++ frontend/Makefile | 3 --- proxy/Dockerfile | 6 ++++++ proxy/Makefile | 3 --- 5 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 .travis.yml create mode 100644 frontend/Dockerfile delete mode 100644 frontend/Makefile create mode 100644 proxy/Dockerfile delete mode 100644 proxy/Makefile diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c6f8055 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,52 @@ +sudo: required +services: + - docker +language: bash +env: + - PROGRAM=frontend IMAGE_NAME=bird-lg-go IMAGE_ARCH=i386 + - PROGRAM=frontend IMAGE_NAME=bird-lg-go IMAGE_ARCH=amd64 + - PROGRAM=frontend IMAGE_NAME=bird-lg-go IMAGE_ARCH=arm32v7 + - PROGRAM=frontend IMAGE_NAME=bird-lg-go IMAGE_ARCH=arm64v8 + - PROGRAM=proxy IMAGE_NAME=bird-lgproxy-go IMAGE_ARCH=i386 + - PROGRAM=proxy IMAGE_NAME=bird-lgproxy-go IMAGE_ARCH=amd64 + - PROGRAM=proxy IMAGE_NAME=bird-lgproxy-go IMAGE_ARCH=arm32v7 + - PROGRAM=proxy IMAGE_NAME=bird-lgproxy-go IMAGE_ARCH=arm64v8 + +install: + - docker run --rm --privileged multiarch/qemu-user-static:register --reset + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + +script: + - | + # Translate to alternative arch names used in multiarch images + if [ "$IMAGE_ARCH" == "amd64" ]; then IMAGE_ARCH_ALT=amd64 ; fi + if [ "$IMAGE_ARCH" == "i386" ]; then IMAGE_ARCH_ALT=i386 ; fi + if [ "$IMAGE_ARCH" == "arm32v7" ]; then IMAGE_ARCH_ALT=armhf ; fi + if [ "$IMAGE_ARCH" == "arm64v8" ]; then IMAGE_ARCH_ALT=aarch64; fi + + # Translate to alternative arch names used in golang + if [ "$IMAGE_ARCH" == "amd64" ]; then IMAGE_ARCH_GO=amd64; fi + if [ "$IMAGE_ARCH" == "i386" ]; then IMAGE_ARCH_GO=386 ; fi + if [ "$IMAGE_ARCH" == "arm32v7" ]; then IMAGE_ARCH_GO=arm ; fi + if [ "$IMAGE_ARCH" == "arm64v8" ]; then IMAGE_ARCH_GO=arm64; fi + + # Build Go binary + GOOS=linux GOARCH=$IMAGE_ARCH_GO go build -ldflags="-s -w" -o $PROGRAM $PROGRAM/*.go + + # Build image + docker build \ + -t $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH \ + -f $PROGRAM/Dockerfile \ + --build-arg IMAGE_ARCH=$IMAGE_ARCH \ + --build-arg IMAGE_ARCH_ALT=$IMAGE_ARCH_ALT \ + --build-arg IMAGE_ARCH_GO=$IMAGE_ARCH_GO \ + $IMAGE_NAME + + # Tag image :{arch} and :{arch}-build{build number} + docker tag $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH-build$TRAVIS_BUILD_NUMBER + if [ "$IMAGE_ARCH" = "amd64" ]; then + # Tag as latest for amd64 images + docker tag $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH $DOCKER_USERNAME/$IMAGE_NAME:latest + docker tag $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH $DOCKER_USERNAME/$IMAGE_NAME:build$TRAVIS_BUILD_NUMBER + fi + - docker push $DOCKER_USERNAME/$IMAGE_NAME diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..e40c364 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,6 @@ +ARG THIS_ARCH_ALT=amd64 +FROM multiarch/alpine:${THIS_ARCH_ALT}-edge + +LABEL Lan Tian "lantian@lantian.pub" +COPY frontend / +ENTRYPOINT ["/frontend"] diff --git a/frontend/Makefile b/frontend/Makefile deleted file mode 100644 index a20aa00..0000000 --- a/frontend/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -all: - go build -ldflags="-s -w" - # upx --best bird-lgproxy-go diff --git a/proxy/Dockerfile b/proxy/Dockerfile new file mode 100644 index 0000000..3b869cc --- /dev/null +++ b/proxy/Dockerfile @@ -0,0 +1,6 @@ +ARG THIS_ARCH_ALT=amd64 +FROM multiarch/alpine:${THIS_ARCH_ALT}-edge + +LABEL Lan Tian "lantian@lantian.pub" +COPY proxy / +ENTRYPOINT ["/proxy"] diff --git a/proxy/Makefile b/proxy/Makefile deleted file mode 100644 index a20aa00..0000000 --- a/proxy/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -all: - go build -ldflags="-s -w" - # upx --best bird-lgproxy-go