Add docker & build on tags

This commit is contained in:
Jannis Mattheis 2018-02-23 19:01:06 +01:00
parent a22ace4f7d
commit 8cffa66531
6 changed files with 60 additions and 6 deletions

View File

@ -1,3 +1,4 @@
sudo: required
language: go language: go
go: go:
- 1.9 - 1.9
@ -5,6 +6,9 @@ go:
notifications: notifications:
email: false email: false
services:
- docker
env: env:
- DEP_VERSION="0.4.1" - DEP_VERSION="0.4.1"
@ -13,6 +17,10 @@ before_install:
- chmod +x $GOPATH/bin/dep - chmod +x $GOPATH/bin/dep
- chmod +x ./all-test-with-coverage.sh - chmod +x ./all-test-with-coverage.sh
- chmod +x ./swagger-validate.sh - chmod +x ./swagger-validate.sh
- chmod +x ./build.sh
- chmod +x ./docker-build.sh
- chmod +x ./docker-push.sh
- mkdir build
install: install:
- dep ensure - dep ensure
@ -31,4 +39,24 @@ script:
- golint -set_exit_status $(go list ./... | grep -v mock) - golint -set_exit_status $(go list ./... | grep -v mock)
after_success: after_success:
- bash <(curl -s https://codecov.io/bash) - bash <(curl -s https://codecov.io/bash)
before_deploy:
- docker pull karalabe/xgo-latest
- go get github.com/karalabe/xgo
- ./build.sh ${TRAVIS_TAG#v}
- ./docker-build.sh ${TRAVIS_TAG#v}
deploy:
- provider: releases
api_key: $GH_TOKEN
file_glob: true
file: build/*.zip
skip_cleanup: true
on:
tags: true
- provider: script
script: bash docker_push.sh
skip_cleanup: true
on:
tags: true

View File

@ -10,7 +10,7 @@ DATE=`date "+%F-%T"`
COMMIT=`git rev-parse --verify HEAD` COMMIT=`git rev-parse --verify HEAD`
BRANCH=`git rev-parse --abbrev-ref HEAD` BRANCH=`git rev-parse --abbrev-ref HEAD`
URL=github.com/gotify/server URL=github.com/gotify/server
PREFIX=gotify-$VERSION PREFIX=gotify
DEST=./build DEST=./build
TARGETS=linux/arm64,linux/amd64,linux/arm-7,windows-10/amd64 TARGETS=linux/arm64,linux/amd64,linux/arm-7,windows-10/amd64
LICENSES=./licenses/ LICENSES=./licenses/
@ -18,15 +18,15 @@ LICENSES=./licenses/
xgo -ldflags "-X main.Version=$VERSION -X main.BuildDate=$DATE -X main.Commit=$COMMIT -X main.Branch=$BRANCH" -targets $TARGETS -dest $DEST -out $PREFIX $URL xgo -ldflags "-X main.Version=$VERSION -X main.BuildDate=$DATE -X main.Commit=$COMMIT -X main.Branch=$BRANCH" -targets $TARGETS -dest $DEST -out $PREFIX $URL
mkdir $LICENSES mkdir $LICENSES
for LICENSE in $(/bin/find vendor/ -name LICENSE | grep -v monkey); do for LICENSE in $(find vendor/ -name LICENSE | grep -v monkey); do
DIR=$(echo $LICENSE | tr "/" _ | sed -e 's/vendor_//; s/_LICENSE//') DIR=$(echo $LICENSE | tr "/" _ | sed -e 's/vendor_//; s/_LICENSE//')
mkdir $LICENSES$DIR mkdir $LICENSES$DIR
cp $LICENSE $LICENSES$DIR cp $LICENSE $LICENSES$DIR
done done
for BIN in build/*; do for BUILD in $(find build/*); do
zip -j $BIN.zip $BIN LICENSE zip -j $BUILD.zip $BUILD ./LICENSE
zip -ur $BIN.zip $LICENSES zip -ur $BUILD.zip $LICENSES
done done
rm -rf $LICENSES rm -rf $LICENSES

13
docker-build.sh Normal file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
if [ $# -eq 0 ]; then
echo You need to pass the version as first parameter.
exit 1
fi
cp ./build/gotify-linux-amd64 ./docker/gotify-app
(cd docker && docker build -t gotify/server:latest -t gotify/server:$1 .)
rm ./docker/gotify-app
cp ./build/gotify-linux-arm-7 ./docker/gotify-app
(cd docker && docker build -f Dockerfile.arm7 -t gotify/server-arm7:latest -t gotify/server-arm7:$1 .)
rm ./docker/gotify-app

5
docker-push.sh Normal file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD";
docker push gotify/server
docker push gotify/server-arm7

4
docker/Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM frolvlad/alpine-glibc
WORKDIR /app
ADD gotify-app /app/
ENTRYPOINT ["./gotify-app"]

4
docker/Dockerfile.arm7 Normal file
View File

@ -0,0 +1,4 @@
FROM resin/armv7hf-debian
WORKDIR /app
ADD gotify-app /app/
ENTRYPOINT ["./gotify-app"]