From cad41e6c11c37ea295aa793764f6d362dde401bd Mon Sep 17 00:00:00 2001 From: Lan Tian Date: Tue, 8 Jan 2019 15:49:54 +0800 Subject: [PATCH] Try to fix travis again... --- .travis.yml | 11 +---------- frontend/Dockerfile | 9 ++++++++- proxy/Dockerfile | 9 ++++++++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index edd198c..059a801 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,6 @@ sudo: required services: - docker -language: go -go: - - "1.10" env: - PROGRAM=frontend IMAGE_NAME=bird-lg-go IMAGE_ARCH=i386 - PROGRAM=frontend IMAGE_NAME=bird-lg-go IMAGE_ARCH=amd64 @@ -17,7 +14,6 @@ env: install: - docker run --rm --privileged multiarch/qemu-user-static:register --reset - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - - sudo apt-get install -y upx script: - | @@ -33,11 +29,6 @@ script: if [ "$IMAGE_ARCH" == "arm32v7" ]; then IMAGE_ARCH_GO=arm ; fi if [ "$IMAGE_ARCH" == "arm64v8" ]; then IMAGE_ARCH_GO=arm64; fi - # Build Go binary - mkdir build - GOOS=linux GOARCH=$IMAGE_ARCH_GO go build -ldflags="-s -w -linkmode external -extldflags \"-static\"" -o build/$PROGRAM $PROGRAM/*.go - upx --best build/$PROGRAM - # Build image docker build \ -t $DOCKER_USERNAME/$IMAGE_NAME:$IMAGE_ARCH \ @@ -45,7 +36,7 @@ script: --build-arg IMAGE_ARCH=$IMAGE_ARCH \ --build-arg IMAGE_ARCH_ALT=$IMAGE_ARCH_ALT \ --build-arg IMAGE_ARCH_GO=$IMAGE_ARCH_GO \ - . + $PROGRAM # 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 diff --git a/frontend/Dockerfile b/frontend/Dockerfile index f0e7e2b..e1b79ed 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -2,5 +2,12 @@ ARG THIS_ARCH_ALT=amd64 FROM multiarch/alpine:${THIS_ARCH_ALT}-edge LABEL Lan Tian "lantian@lantian.pub" -COPY build/frontend / +ENV GOOS=linux GOARCH=${THIS_ARCH_GO} +WORKDIR /root +COPY . . +RUN apk -q --no-cache add git go build-base upx \ + && cd /root && go build -o /frontend && upx /frontend \ + && cd / && rm -rf /root/* \ + && apk del go build-base upx + ENTRYPOINT ["/frontend"] diff --git a/proxy/Dockerfile b/proxy/Dockerfile index c0c04de..c2c463d 100644 --- a/proxy/Dockerfile +++ b/proxy/Dockerfile @@ -2,5 +2,12 @@ ARG THIS_ARCH_ALT=amd64 FROM multiarch/alpine:${THIS_ARCH_ALT}-edge LABEL Lan Tian "lantian@lantian.pub" -COPY build/proxy / +ENV GOOS=linux GOARCH=${THIS_ARCH_GO} +WORKDIR /root +COPY . . +RUN apk -q --no-cache add git go build-base upx \ + && cd /root && go build -o /proxy && upx /proxy \ + && cd / && rm -rf /root/* \ + && apk del go build-base upx + ENTRYPOINT ["/proxy"]