From 9ad7519cd9864d9713e8783503b525465c184220 Mon Sep 17 00:00:00 2001 From: Hunter Long Date: Sun, 24 Jun 2018 00:38:50 -0700 Subject: [PATCH] building --- .travis.yml | 3 ++- Dockerfile | 25 ++++++++++--------------- build.sh | 2 ++ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 69718eff..5a0b8825 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ services: env: global: - - VERSION=0.2 + - VERSION=0.21 matrix: allow_failures: @@ -40,6 +40,7 @@ deploy: - "build/statup-linux-arm64" - "build/statup-linux-arm7" - "build/statup-windows-x64.exe" + - "build/statup-alpine" skip_cleanup: true notifications: diff --git a/Dockerfile b/Dockerfile index d8122880..10c5f177 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,12 @@ -FROM golang:1.10.3-alpine - -RUN apk update && apk add git g++ - -WORKDIR $GOPATH/src/github.com/hunterlong/statup/ -RUN go get github.com/GeertJohan/go.rice/rice -COPY . $GOPATH/src/github.com/hunterlong/statup/ -RUN go get -RUN rice embed-go -RUN go install +FROM golang:1.10.3 as builder +WORKDIR /go/src/github.com/hunterlong/statup +COPY . . +RUN go get -d -v +RUN CGO_ENABLED=0 GOOS=linux go build -a -o statup . +FROM alpine:latest +RUN apk --no-cache add ca-certificates WORKDIR /app -VOLUME /app - -EXPOSE 8080 - -CMD ["/go/bin/statup"] \ No newline at end of file +COPY --from=builder /go/src/github.com/hunterlong/statup /app/ +RUN chmod +x /app/statup +CMD ["./statup", "version"] \ No newline at end of file diff --git a/build.sh b/build.sh index 33c8bf22..c4dfc059 100755 --- a/build.sh +++ b/build.sh @@ -14,6 +14,8 @@ xgo -go 1.10.x --targets=windows-6.0/amd64 --dest=build -ldflags="-X main.VERSIO xgo -go 1.10.x --targets=linux/arm-7 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ xgo -go 1.10.x --targets=linux/arm64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ +CGO_ENABLED=0 GOOS=linux go build -ldflags="-X main.VERSION=$VERSION" -a -o build/statup-alpine . + cd build ls cd ../