Automatically build, tag and push docker images on merge to master (#103)
* port changes * build overlay on successful merge to master * fixes to Makefile * permissions * dep ensure * gopath * let's try vgo * remove dep * maybe alpine is the issue * tagging go version on build * stupid vgo * vgo * adding tags to push * quotes * local linting fixes & stupid travis
This commit is contained in:
parent
c6f8144221
commit
2181932e31
17
.travis.yml
17
.travis.yml
@ -1,9 +1,19 @@
|
||||
# make use of vm's
|
||||
sudo: 'required'
|
||||
|
||||
# have the docker service set up (we'll
|
||||
# update it later)
|
||||
services:
|
||||
- 'docker'
|
||||
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.10.x
|
||||
|
||||
before_install:
|
||||
- './.travis/main.sh'
|
||||
- echo -e "machine api.github.com login coyle password $GITHUB_TOKEN" >> ~/.netrc
|
||||
- source scripts/travis-deps.sh
|
||||
|
||||
install:
|
||||
@ -11,3 +21,10 @@ install:
|
||||
|
||||
script:
|
||||
- make test
|
||||
- make images
|
||||
|
||||
after_success:
|
||||
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then
|
||||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin ;
|
||||
make push-images ;
|
||||
fi
|
||||
|
61
.travis/main.sh
Executable file
61
.travis/main.sh
Executable file
@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Set an option to exit immediately if any error appears
|
||||
set -o errexit
|
||||
|
||||
# Main function that describes the behavior of the
|
||||
# script.
|
||||
# By making it a function we can place our methods
|
||||
# below and have the main execution described in a
|
||||
# concise way via function invocations.
|
||||
main() {
|
||||
setup_dependencies
|
||||
update_docker_configuration
|
||||
|
||||
echo "SUCCESS:
|
||||
Done! Finished setting up Travis machine.
|
||||
"
|
||||
}
|
||||
|
||||
# Prepare the dependencies that the machine need.
|
||||
# Here I'm just updating the apt references and then
|
||||
# installing both python and python-pip. This allows
|
||||
# us to make use of `pip` to fetch the latest `docker-compose`
|
||||
# later.
|
||||
# We also upgrade `docker-ce` so that we can get the
|
||||
# latest docker version which allows us to perform
|
||||
# image squashing as well as multi-stage builds.
|
||||
setup_dependencies() {
|
||||
echo "INFO:
|
||||
Setting up dependencies.
|
||||
"
|
||||
|
||||
sudo apt update -y
|
||||
sudo apt install realpath python python-pip -y
|
||||
sudo apt install --only-upgrade docker-ce -y
|
||||
|
||||
sudo pip install docker-compose || true
|
||||
|
||||
docker info
|
||||
docker-compose --version
|
||||
}
|
||||
|
||||
# Tweak the daemon configuration so that we
|
||||
# can make use of experimental features (like image
|
||||
# squashing) as well as have a bigger amount of
|
||||
# concurrent downloads and uploads.
|
||||
update_docker_configuration() {
|
||||
echo "INFO:
|
||||
Updating docker configuration
|
||||
"
|
||||
|
||||
echo '{
|
||||
"experimental": true,
|
||||
"storage-driver": "overlay2",
|
||||
"max-concurrent-downloads": 50,
|
||||
"max-concurrent-uploads": 50
|
||||
}' | sudo tee /etc/docker/daemon.json
|
||||
sudo service docker restart
|
||||
}
|
||||
|
||||
main
|
10
Dockerfile
10
Dockerfile
@ -1,7 +1,11 @@
|
||||
# env
|
||||
ARG VERSION
|
||||
# build
|
||||
FROM golang:alpine AS build-env
|
||||
ADD . /go/src/storj.io/storj
|
||||
RUN cd /go/src/storj.io/storj/cmd/overlay && go build -o overlay
|
||||
FROM golang:${VERSION} AS build-env
|
||||
COPY . /go/src/storj.io/storj
|
||||
RUN go get -u -v golang.org/x/vgo
|
||||
RUN cd /go/src/storj.io/storj && vgo install ./...
|
||||
RUN cd /go/src/storj.io/storj/cmd/overlay && vgo build -o overlay
|
||||
|
||||
|
||||
# final stage
|
||||
|
13
Makefile
13
Makefile
@ -1,10 +1,14 @@
|
||||
.PHONY: test lint proto check-copyrights build-dev-deps
|
||||
|
||||
TAG := $$(git rev-parse --short HEAD)
|
||||
GO_VERSION := 1.10
|
||||
|
||||
lint: check-copyrights
|
||||
@echo "Running ${@}"
|
||||
@gometalinter \
|
||||
--deadline=170s \
|
||||
--disable-all \
|
||||
--vendor .\
|
||||
--enable=golint \
|
||||
--enable=goimports \
|
||||
--enable=vet \
|
||||
@ -12,6 +16,7 @@ lint: check-copyrights
|
||||
--enable=goconst \
|
||||
--exclude=.*\.pb\.go \
|
||||
--exclude=.*_test.go \
|
||||
--exclude=./vendor/* \
|
||||
./...
|
||||
|
||||
check-copyrights:
|
||||
@ -66,3 +71,11 @@ clean-local:
|
||||
docker rm redis || true
|
||||
# cleanup docker network
|
||||
docker network rm test-net || true
|
||||
|
||||
images:
|
||||
docker build --build-arg VERSION=${GO_VERSION} -t overlay:${TAG}-${GO_VERSION} .
|
||||
docker tag overlay:${TAG}-${GO_VERSION} overlay:latest
|
||||
|
||||
push-images:
|
||||
docker push storjlabs/overlay:${TAG}-${GO_VERSION}
|
||||
docker push storjlabs/overlay:latest
|
1
go.mod
1
go.mod
@ -30,6 +30,7 @@ require (
|
||||
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572
|
||||
github.com/spf13/afero v1.1.0
|
||||
github.com/spf13/cast v1.2.0
|
||||
github.com/spf13/jwalterweatherman v0.0.0-20180109140146-7c0cea34c8ec
|
||||
github.com/spf13/pflag v1.0.1
|
||||
github.com/spf13/viper v1.0.2
|
||||
github.com/tyler-smith/go-bip39 v0.0.0-20160629163856-8e7a99b3e716
|
||||
|
@ -1,6 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
FILES=$(find $PWD -type f \( -iname '*.go' ! -iname "*.pb.go" \) )
|
||||
FILES=$(find $PWD -type f ! -path '*vendor/*' \( -iname '*.go' ! -iname "*.pb.go" \))
|
||||
for i in $FILES
|
||||
do
|
||||
if ! grep -q 'Copyright' <<< "$(head -n 2 "$i")"
|
||||
|
Loading…
Reference in New Issue
Block a user