Skip to content

Commit

Permalink
Merge branch 'develop' into FD-50
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/messages/addServer.go
#	common/messages/eom.go
#	common/messages/missingData.go
#	common/messages/missingMsg.go
#	common/messages/missingMsgResponse.go
#	common/messages/revealEntry.go
  • Loading branch information
ThePiachu committed Oct 19, 2017
2 parents ef68dca + 5f5e000 commit 8ed5931
Show file tree
Hide file tree
Showing 265 changed files with 17,951 additions and 3,346 deletions.
247 changes: 247 additions & 0 deletions .circleci/config.yml
@@ -0,0 +1,247 @@
version: 2

jobs:

build:
working_directory: /go/src/github.com/FactomProject/factomd
docker:
- image: circleci/golang:1.9

steps:
- checkout

- restore_cache:
keys:
- v1-factomd-go-build-cache-{{ checksum "glide.lock" }}

- run:
name: Get glide
command: |
go get -v github.com/Masterminds/glide
cd $GOPATH/src/github.com/Masterminds/glide
git checkout tags/v0.12.3
go install
- run:
name: Get goveralls
command: |
go get github.com/mattn/goveralls
cd $GOPATH/src/github.com/Masterminds/glide
git checkout tags/v0.12.3
go install
- run:
name: Get the dependencies
command: |
glide install
- run:
name: Build and install the executable
command: go install -v

- save_cache:
key: v1-factomd-go-build-cache-{{ checksum "glide.lock" }}
paths:
- vendor

test:
working_directory: /go/src/github.com/FactomProject/factomd
docker:
- image: circleci/golang:1.9

steps:
- checkout

- restore_cache:
keys:
- v1-factomd-go-build-cache-{{ checksum "glide.lock" }}

- run:
name: Get glide
command: |
go get -v github.com/Masterminds/glide
cd $GOPATH/src/github.com/Masterminds/glide
git checkout tags/v0.12.3
go install
- run:
name: Get goveralls
command: |
go get github.com/mattn/goveralls
cd $GOPATH/src/github.com/Masterminds/glide
git checkout tags/v0.12.3
go install
- run:
name: Get the dependencies
command: |
glide install
- run:
name: Build and install the executable
command: go install -v

- run:
name: Run tests!
no_output_timeout: 2400
command: go test -v $(glide nv)


- save_cache:
key: v1-factomd-go-build-cache-{{ checksum "glide.lock" }}
paths:
- vendor

coveralls:
working_directory: /go/src/github.com/FactomProject/factomd
docker:
- image: circleci/golang:1.9

steps:
- checkout

- restore_cache:
keys:
- v1-factomd-go-build-cache-{{ checksum "glide.lock" }}

- run:
name: Get glide
command: |
go get -v github.com/Masterminds/glide
cd $GOPATH/src/github.com/Masterminds/glide
git checkout tags/v0.12.3
go install
- run:
name: Get goveralls
command: |
go get github.com/mattn/goveralls
cd $GOPATH/src/github.com/Masterminds/glide
git checkout tags/v0.12.3
go install
- run:
name: Get the dependencies
command: |
glide install
- run:
name: Build and install the executable
command: go install -v

- run:
name: Coveralls!
no_output_timeout: 2400
command: goveralls -v -ignore=$(paste -sd, .coverignore) -service=circle-ci -repotoken=$COVERALLS_TOKEN


- save_cache:
key: v1-factomd-go-build-cache-{{ checksum "glide.lock" }}
paths:
- vendor



# Docker builds
docker_build:
working_directory: /go/src/github.com/FactomProject/factomd

docker:
- image: docker:17.06.0-ce-git

steps:
- checkout

- setup_remote_docker:
version: 17.06.0-ce

# The main (only) thing we care about is caching the /vendor dir.
# Hence, checksumming glide.lock
- restore_cache:
keys:
- v5-factomd-cache-{{ checksum "glide.lock" }}

# Load the images if the cache hit
- run:
name: Load Docker image layer cache
command: |
set +o pipefail
docker load -i /images/factomd-alpine.tar | true
docker load -i /images/factomd.tar | true
# Build the containers
- run:
name: Build the baseline images
command: |
docker build -t factomd-alpine -f Dockerfile.alpine .
docker build -t factomd -f Dockerfile .
# Push, depending on branch/tag
- run:
name: Push master / develop to DockerHub
command: |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
if [ "${CIRCLE_BRANCH}" == "master" ]; then
# If there is a tag, use it
if [ "$CIRCLE_TAG" != "" ]; then
docker tag factomd-alpine factominc/factomd:${TAG}-alpine
docker push factominc/factomd:${TAG}-alpine
docker tag factomd factominc/factomd:${TAG}
docker push factominc/factomd:${TAG}
fi
# But tag it as alpine/latest anyhow
docker tag factomd-alpine factominc/factomd:alpine
docker push factominc/factomd:alpine
docker tag factomd factominc/factomd:latest
docker push factominc/factomd:latest
elif [ "${CIRCLE_BRANCH}" == "develop" ]; then
# If there is a tag, use it
if [ "$CIRCLE_TAG" != "" ]; then
docker tag factomd-alpine factominc/factomd:${TAG}-alpine-develop
docker push factominc/factomd:${TAG}-alpine-develop
docker tag factomd factominc/factomd:${TAG}-develop
docker push factominc/factomd:${TAG}-develop
fi
# But tag it as alpine-develop/develop anyhow
docker tag factomd-alpine factominc/factomd:alpine-develop
docker push factominc/factomd:alpine-develop
docker tag factomd factominc/factomd:develop
docker push factominc/factomd:develop
fi
docker logout
- run:
name: Save the image cache
command: |
mkdir -p /images
docker save -o /images/factomd-alpine.tar factomd-alpine $(docker history -q factomd-alpine |grep -v missing | grep -v none)
docker save -o /images/factomd.tar factomd $(docker history -q factomd |grep -v missing | grep -v none)
- save_cache:
key: v5-factomd-cache-{{ checksum "glide.lock" }}
paths:
- /images

# The flow is
# build
# |
# ---------- test
# |
# ---------- coveralls
# |
# ---------- docker_build
#
#
workflows:
version: 2
build:
jobs:
- build
- test:
requires:
- build
- coveralls:
requires:
- test
- docker_build:
context: org-global
requires:
- test
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

29 changes: 23 additions & 6 deletions Docker.md
Expand Up @@ -52,25 +52,42 @@ In all cases, you can startup with additional flags by passing them at the end o
So yeah, you want to get your binary _out_ of the container. To do so, you basically mount your target into the container, and copy the binary over, like so


`docker run --rm --entrypoint='' -v <FULLY_QUALIFIED_PATH_TO_TARGET_DIRECTORY>:/destination factomd_container /bin/cp /go/bin/factomd /destination`
```
docker run --rm --entrypoint='' \
-v <FULLY_QUALIFIED_PATH_TO_TARGET_DIRECTORY>:/destination factomd_container \
/bin/cp /go/bin/factomd /destination
```

e.g.

`docker run --rm --entrypoint='' -v /tmp:/destination factomd_container /bin/cp /go/bin/factomd /destination`
```
docker run --rm --entrypoint='' \
-v /tmp:/destination factomd_container \
/bin/cp /go/bin/factomd /destination
```

which will copy the binary to `/tmp/factomd`

**Note** : You should replace ** factomd_container** with whatever you called it in the **build** section above e.g. **factomd**, **foo**, etc.
**Note** : You should replace **factomd_container** with whatever you called it in the [build](#build) section above e.g. **factomd**, **foo**, etc.

#### Cross-Compile
If you cross-compiled to a different target, your binary will be in `/go/bin/<target>/factomd`. e.g. If you built with `--build-arg GOOS=darwin`, then you can copy out the binary with

`docker run --rm --entrypoint='' -v <FULLY_QUALIFIED_PATH_TO_TARGET_DIRECTORY>:/destination factomd_container /bin/cp /go/bin/darwin_amd64/factomd /destination`
```
docker run --rm --entrypoint='' \
-v <FULLY_QUALIFIED_PATH_TO_TARGET_DIRECTORY>:/destination \
factomd_container \
/bin/cp /go/bin/darwin_amd64/factomd /destination
```

e.g.

`docker run --rm --entrypoint='' -v /tmp:/destination factomd_container /bin/cp /go/bin/darwin_amd64/factomd /destination`
```
docker run --rm --entrypoint=''
-v /tmp:/destination factomd_container \
/bin/cp /go/bin/darwin_amd64/factomd /destination
```

which will copy the darwin_amd64 version of the binary to `/tmp/factomd`

**Note** : You should replace ** factomd_container** with whatever you called it in the **build** section above e.g. **factomd**, **foo**, etc.
**Note** : You should replace **factomd_container** with whatever you called it in the **build** section above e.g. **factomd**, **foo**, etc.
18 changes: 13 additions & 5 deletions Dockerfile
@@ -1,24 +1,32 @@
FROM golang:1.8.3-alpine
FROM golang:1.9

# Get git
RUN apk add --no-cache curl git
RUN apt-get update \
&& apt-get -y install curl git \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Get glide
RUN go get github.com/Masterminds/glide

# Where factomd sources will live
WORKDIR $GOPATH/src/github.com/FactomProject/factomd

# Populate the source
COPY . .
# Get the dependencies
COPY glide.yaml glide.lock ./

# Install dependencies
RUN glide install -v

# Get goveralls for testing/coverage
RUN go get github.com/mattn/goveralls

# Populate the rest of the source
COPY . .

ARG GOOS=linux

# Build and install factomd
RUN go install -ldflags "-X github.com/FactomProject/factomd/engine.Build=`git rev-parse HEAD`"
RUN go install -ldflags "-X github.com/FactomProject/factomd/engine.Build=`git rev-parse HEAD` -X github.com/FactomProject/factomd/engine.FactomdVersion=`cat VERSION`"

# Setup the cache directory
RUN mkdir -p /root/.factom/m2
Expand Down
42 changes: 42 additions & 0 deletions Dockerfile.alpine
@@ -0,0 +1,42 @@
FROM golang:1.9-alpine as builder

# Get git
RUN apk add --no-cache curl git

# Get glide
RUN go get github.com/Masterminds/glide

# Where factomd sources will live
WORKDIR $GOPATH/src/github.com/FactomProject/factomd

# Get the dependencies
COPY glide.yaml glide.lock ./

# Install dependencies
RUN glide install -v

# Populate the rest of the source
COPY . .

ARG GOOS=linux

# Build and install factomd
RUN go install -ldflags "-X github.com/FactomProject/factomd/engine.Build=`git rev-parse HEAD` -X github.com/FactomProject/factomd/engine.FactomdVersion=`cat VERSION`"

# Setup the cache directory
RUN mkdir -p /root/.factom/m2
COPY factomd.conf /root/.factom/m2/factomd.conf

# Now squash everything
FROM alpine:3.6

# Get git
RUN apk add --no-cache ca-certificates curl git

RUN mkdir -p /root/.factom/m2 /go/bin
COPY --from=builder /root/.factom/m2/factomd.conf /root/.factom/m2/factomd.conf
COPY --from=builder /go/bin/factomd /go/bin/factomd

ENTRYPOINT ["/go/bin/factomd"]

EXPOSE 8088 8090 8108 8109 8110

0 comments on commit 8ed5931

Please sign in to comment.