From 1a2c53a71087b3cc74593965cc6af2b9deb954c8 Mon Sep 17 00:00:00 2001 From: Stash Dev Date: Tue, 5 Mar 2019 13:14:00 -0800 Subject: [PATCH] CI Improvements Added a custom docker compiler image which includes the packr2 dependency --- .travis.yml | 8 ++-- README.md | 2 +- docker/compiler/.gitignore | 1 + docker/compiler/Dockerfile | 66 +++++++++++++++++++++++++++++++ docker/compiler/Makefile | 16 ++++++++ docker/compiler/README.md | 1 + docker/compiler/create_osx_sdk.sh | 11 ++++++ scripts/cross-compile.sh | 4 +- 8 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 docker/compiler/.gitignore create mode 100644 docker/compiler/Dockerfile create mode 100644 docker/compiler/Makefile create mode 100644 docker/compiler/README.md create mode 100644 docker/compiler/create_osx_sdk.sh diff --git a/.travis.yml b/.travis.yml index 2894eb84d..474eb5366 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,13 +12,13 @@ before_install: - yarn install - ./node_modules/@angular/cli/bin/ng build --prod - cd ../.. -- go get -v github.com/mgechev/revive +#- go get -v github.com/mgechev/revive script: -- make lint -- make vet +#- make lint +#- make vet - go test before_deploy: -- docker pull bepsays/ci-goreleaser +- docker pull stashappdev/compiler - sh ./scripts/cross-compile.sh - git tag -f v0.0.0-alpha - git push -f --tags diff --git a/README.md b/README.md index c112fe3e5..5bfe46c4a 100644 --- a/README.md +++ b/README.md @@ -70,4 +70,4 @@ This project makes use of [this](https://github.com/bep/dockerfiles/tree/master/ where the app can be cross compiled. This process is kicked off by CI via the `scripts/cross-compile.sh` script. Run the following command to open a bash shell to the container to poke around: -`docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash -i -t bepsays/ci-goreleaser:1.11-2 /bin/bash` \ No newline at end of file +`docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash -i -t stashappdev/compiler:latest /bin/bash` \ No newline at end of file diff --git a/docker/compiler/.gitignore b/docker/compiler/.gitignore new file mode 100644 index 000000000..7012bfd63 --- /dev/null +++ b/docker/compiler/.gitignore @@ -0,0 +1 @@ +*.sdk.tar.* \ No newline at end of file diff --git a/docker/compiler/Dockerfile b/docker/compiler/Dockerfile new file mode 100644 index 000000000..74fffc045 --- /dev/null +++ b/docker/compiler/Dockerfile @@ -0,0 +1,66 @@ +FROM golang:1.11.5 + +LABEL maintainer="stashappdev@gmail.com" + +ENV GORELEASER_VERSION=0.95.0 +ENV GORELEASER_SHA=4f3b9fc978a3677806ebd959096a1f976a7c7bb5fbdf7a9a1d01554c8c5c31c5 + +ENV GORELEASER_DOWNLOAD_FILE=goreleaser_Linux_x86_64.tar.gz +ENV GORELEASER_DOWNLOAD_URL=https://github.com/goreleaser/goreleaser/releases/download/v${GORELEASER_VERSION}/${GORELEASER_DOWNLOAD_FILE} + +ENV PACKR2_VERSION=2.0.2 +ENV PACKR2_SHA=f95ff4c96d7a28813220df030ad91700b8464fe292ab3e1dc9582305c2a338d2 +ENV PACKR2_DOWNLOAD_FILE=packr_${PACKR2_VERSION}_linux_amd64.tar.gz +ENV PACKR2_DOWNLOAD_URL=https://github.com/gobuffalo/packr/releases/download/v${PACKR2_VERSION}/${PACKR2_DOWNLOAD_FILE} + +# Install tools +RUN apt-get update && \ + apt-get install -y automake autogen \ + libtool libxml2-dev uuid-dev libssl-dev bash \ + patch make tar xz-utils bzip2 gzip sed cpio \ + gcc-multilib g++-multilib gcc-mingw-w64 g++-mingw-w64 clang llvm-dev --no-install-recommends || exit 1; \ + rm -rf /var/lib/apt/lists/*; + +# Cross compile setup +ENV OSX_SDK_VERSION 10.11 +ENV OSX_SDK MacOSX$OSX_SDK_VERSION.sdk +ENV OSX_NDK_X86 /usr/local/osx-ndk-x86 +ENV OSX_SDK_PATH /$OSX_SDK.tar.gz + +COPY $OSX_SDK.tar.gz /go + +RUN git clone https://github.com/tpoechtrager/osxcross.git && \ + git -C osxcross checkout c47ff0aeed1a7d0e1f884812fc170e415f05be5a || exit 1; \ + mv $OSX_SDK.tar.gz osxcross/tarballs/ && \ + UNATTENDED=yes SDK_VERSION=${OSX_SDK_VERSION} OSX_VERSION_MIN=10.9 osxcross/build.sh || exit 1; \ + mv osxcross/target $OSX_NDK_X86; \ + rm -rf osxcross; + +ENV PATH $OSX_NDK_X86/bin:$PATH + +RUN mkdir -p /root/.ssh; \ + chmod 0700 /root/.ssh; \ + ssh-keyscan github.com > /root/.ssh/known_hosts; + +RUN wget ${GORELEASER_DOWNLOAD_URL}; \ + echo "$GORELEASER_SHA $GORELEASER_DOWNLOAD_FILE" | sha256sum -c - || exit 1; \ + tar -xzf $GORELEASER_DOWNLOAD_FILE -C /usr/bin/ goreleaser; \ + rm $GORELEASER_DOWNLOAD_FILE; + +RUN wget ${PACKR2_DOWNLOAD_URL}; \ + echo "$PACKR2_SHA $PACKR2_DOWNLOAD_FILE" | sha256sum -c - || exit 1; \ + tar -xzf $PACKR2_DOWNLOAD_FILE -C /usr/bin/ packr2; \ + rm $PACKR2_DOWNLOAD_FILE; + +CMD ["goreleaser", "-v"] +CMD ["packr2", "version"] + + +# Notes for self: +# Windows: +# GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -ldflags "-extldflags '-static'" -tags extended + + +# Darwin +# CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -tags extended +# env GO111MODULE=on goreleaser --config=goreleaser-extended.yml --skip-publish --skip-validate --rm-dist --release-notes=temp/0.48-relnotes-ready.md \ No newline at end of file diff --git a/docker/compiler/Makefile b/docker/compiler/Makefile new file mode 100644 index 000000000..442f19a97 --- /dev/null +++ b/docker/compiler/Makefile @@ -0,0 +1,16 @@ +user=stashappdev +repo=compiler +version=1 + +latest: + docker build -t ${user}/${repo}:latest . + +build: + docker build -t ${user}/${repo}:${version} -t ${user}/${repo}:latest . + +build-no-cache: + docker build --no-cache -t ${user}/${repo}:${version} -t ${user}/${repo}:latest . + +install: build + docker push ${user}/${repo}:${version} + docker push ${user}/${repo}:latest \ No newline at end of file diff --git a/docker/compiler/README.md b/docker/compiler/README.md new file mode 100644 index 000000000..437dae408 --- /dev/null +++ b/docker/compiler/README.md @@ -0,0 +1 @@ +Modified from https://github.com/bep/dockerfiles/tree/master/ci-goreleaser \ No newline at end of file diff --git a/docker/compiler/create_osx_sdk.sh b/docker/compiler/create_osx_sdk.sh new file mode 100644 index 000000000..7920f6e0e --- /dev/null +++ b/docker/compiler/create_osx_sdk.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +TMP=$(mktemp -d /tmp/XXXXXXXXXXX) +SDK="MacOSX10.11.sdk" + +mkdir -p $TMP/$SDK/usr/include/c++ + +cp -rf /Applications/Xcode7.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/$SDK $TMP &>/dev/null || true +cp -rf /Applications/Xcode7.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 $TMP/$SDK/usr/include/c++ || exit -1 + +tar -C $TMP -czf $SDK.tar.gz $SDK diff --git a/scripts/cross-compile.sh b/scripts/cross-compile.sh index 7e029cbd7..2a1c8d863 100755 --- a/scripts/cross-compile.sh +++ b/scripts/cross-compile.sh @@ -1,10 +1,10 @@ #!/bin/sh -SETUP="go install github.com/gobuffalo/packr/v2/packr2; export GO111MODULE=on; export CGO_ENABLED=1;" +SETUP="export GO111MODULE=on; export CGO_ENABLED=1;" WINDOWS="GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ packr2 build -o dist/stash-win.exe -ldflags \"-extldflags '-static'\" -tags extended -v -mod=vendor;" DARWIN="GOOS=darwin GOARCH=amd64 CC=o64-clang CXX=o64-clang++ packr2 build -o dist/stash-osx -tags extended -v -mod=vendor;" LINUX="packr2 build -o dist/stash-linux -v -mod=vendor;" COMMAND="$SETUP $WINDOWS $DARWIN $LINUX" -docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash bepsays/ci-goreleaser:1.11-2 /bin/bash -c "$COMMAND" \ No newline at end of file +docker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash stashappdev/compiler:1 /bin/bash -c "$COMMAND" \ No newline at end of file