Skip to content

Commit

Permalink
Switch to new baseimage-pipeline
Browse files Browse the repository at this point in the history
We now have baseimage in its own repository.  We also
bake a lot more of the image in during baseimage
creation, so we can relax some of the logic here.

Fixes FAB-284

Change-Id: I489004800635a126cff78dab79134fac9ae24722
Signed-off-by: Gregory Haskins <gregory.haskins@gmail.com>
  • Loading branch information
ghaskins committed Sep 21, 2016
1 parent 79b70e4 commit ac8ab84
Show file tree
Hide file tree
Showing 31 changed files with 20 additions and 2,127 deletions.
1 change: 1 addition & 0 deletions .baseimage-release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0
40 changes: 17 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,16 @@ else
PROJECT_VERSION=$(BASE_VERSION)
endif

DOCKER_TAG=$(shell uname -m)-$(PROJECT_VERSION)

PKGNAME = github.com/$(PROJECT_NAME)
GO_LDFLAGS = -X github.com/hyperledger/fabric/metadata.Version=$(PROJECT_VERSION)
CGO_FLAGS = CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy"
UID = $(shell id -u)
ARCH=$(shell uname -m)
CHAINTOOL_RELEASE=v0.9.0
BASEIMAGE_RELEASE=$(shell cat ./.baseimage-release)

DOCKER_TAG=$(ARCH)-$(PROJECT_VERSION)
BASE_DOCKER_TAG=$(ARCH)-$(BASEIMAGE_RELEASE)

EXECUTABLES = go docker git curl
K := $(foreach exec,$(EXECUTABLES),\
Expand All @@ -63,13 +66,9 @@ K := $(foreach exec,$(EXECUTABLES),\
SUBDIRS = gotools sdk/node
SUBDIRS:=$(strip $(SUBDIRS))

# Make our baseimage depend on any changes to images/base or scripts/provision
BASEIMAGE_RELEASE = $(shell cat ./images/base/release)
BASEIMAGE_DEPS = $(shell git ls-files images/base scripts/provision)

JAVASHIM_DEPS = $(shell git ls-files core/chaincode/shim/java)
PROJECT_FILES = $(shell git ls-files)
IMAGES = base src ccenv peer membersrvc javaenv
IMAGES = src ccenv peer membersrvc javaenv

all: peer membersrvc checks

Expand Down Expand Up @@ -122,14 +121,14 @@ linter: gotools
# we may later inject the binary into a different docker environment
# This is necessary since we cannot guarantee that binaries built
# on the host natively will be compatible with the docker env.
%/bin/protoc-gen-go: build/image/base/.dummy Makefile
%/bin/protoc-gen-go: Makefile
@echo "Building $@"
@mkdir -p $(@D)
@docker run -i \
--user=$(UID) \
-v $(abspath vendor/github.com/golang/protobuf):/opt/gopath/src/github.com/golang/protobuf \
-v $(abspath $(@D)):/opt/gopath/bin \
hyperledger/fabric-baseimage go install github.com/golang/protobuf/protoc-gen-go
hyperledger/fabric-baseimage:$(BASE_DOCKER_TAG) go install github.com/golang/protobuf/protoc-gen-go

build/bin/chaintool: Makefile
@echo "Installing chaintool"
Expand Down Expand Up @@ -172,25 +171,19 @@ build/bin/block-listener:
@echo "Binary available as $@"
@touch $@

build/bin/%: build/image/base/.dummy $(PROJECT_FILES)
build/bin/%: $(PROJECT_FILES)
@mkdir -p $(@D)
@echo "$@"
$(CGO_FLAGS) GOBIN=$(abspath $(@D)) go install -ldflags "$(GO_LDFLAGS)" $(PKGNAME)/$(@F)
@echo "Binary available as $@"
@touch $@

# Special override for base-image.
build/image/base/.dummy: $(BASEIMAGE_DEPS)
@echo "Building docker base-image"
@mkdir -p $(@D)
@./scripts/provision/docker.sh $(BASEIMAGE_RELEASE)
@touch $@

# Special override for src-image
build/image/src/.dummy: build/image/base/.dummy $(PROJECT_FILES)
build/image/src/.dummy: $(PROJECT_FILES)
@echo "Building docker src-image"
@mkdir -p $(@D)
@cat images/src/Dockerfile.in \
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
> $(@D)/Dockerfile
@git ls-files | tar -jcT - > $(@D)/gopath.tar.bz2
Expand All @@ -202,6 +195,7 @@ build/image/src/.dummy: build/image/base/.dummy $(PROJECT_FILES)
build/image/ccenv/.dummy: build/image/src/.dummy build/image/ccenv/bin/protoc-gen-go build/image/ccenv/bin/chaintool Makefile
@echo "Building docker ccenv-image"
@cat images/ccenv/Dockerfile.in \
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
> $(@D)/Dockerfile
docker build -t $(PROJECT_NAME)-ccenv $(@D)
Expand All @@ -216,7 +210,10 @@ build/image/ccenv/.dummy: build/image/src/.dummy build/image/ccenv/bin/protoc-ge
build/image/javaenv/.dummy: Makefile $(JAVASHIM_DEPS)
@echo "Building docker javaenv-image"
@mkdir -p $(@D)
@cat images/javaenv/Dockerfile.in > $(@D)/Dockerfile
@cat images/javaenv/Dockerfile.in \
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
> $(@D)/Dockerfile
@git ls-files core/chaincode/shim/java | tar -jcT - > $(@D)/javashimsrc.tar.bz2
@git ls-files protos core/chaincode/shim/table.proto settings.gradle | tar -jcT - > $(@D)/protos.tar.bz2
docker build -t $(PROJECT_NAME)-javaenv $(@D)
Expand All @@ -229,6 +226,7 @@ build/image/%/.dummy: build/image/src/.dummy build/docker/bin/%
@echo "Building docker $(TARGET)-image"
@mkdir -p $(@D)/bin
@cat images/app/Dockerfile.in \
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
> $(@D)/Dockerfile
cp build/docker/bin/$(TARGET) $(@D)/bin
Expand All @@ -240,10 +238,6 @@ build/image/%/.dummy: build/image/src/.dummy build/docker/bin/%
protos: gotools
./devenv/compile_protos.sh

base-image-clean:
-docker rmi -f $(PROJECT_NAME)-baseimage
-@rm -rf build/image/base ||:

src-image-clean: ccenv-image-clean peer-image-clean membersrvc-image-clean

%-image-clean:
Expand Down
2 changes: 1 addition & 1 deletion devenv/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cd #{SRCMOUNT}/devenv
SCRIPT

baseimage_release = File.read '../images/base/release'
baseimage_release = File.read '../.baseimage-release'

Vagrant.require_version ">= 1.7.4"
Vagrant.configure('2') do |config|
Expand Down
19 changes: 0 additions & 19 deletions devenv/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,6 @@ DEVENV_REVISION=`(cd /hyperledger/devenv; git rev-parse --short HEAD)`
SCRIPT_DIR="$(readlink -f "$(dirname "$0")")"
cat "$SCRIPT_DIR/failure-motd.in" >> /etc/motd

# Update system
apt-get update -qq

# Prep apt-get for docker install
apt-get install -y apt-transport-https ca-certificates
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

# Add docker repository
echo deb https://apt.dockerproject.org/repo ubuntu-trusty main > /etc/apt/sources.list.d/docker.list

# Update system
apt-get update -qq

# Storage backend logic
case "${DOCKER_STORAGE_BACKEND}" in
aufs|AUFS|"")
Expand All @@ -72,9 +59,6 @@ case "${DOCKER_STORAGE_BACKEND}" in
exit 1;;
esac

# Install docker
apt-get install -y linux-image-extra-$(uname -r) apparmor docker-engine

# Configure docker
DOCKER_OPTS="-s=${DOCKER_STORAGE_BACKEND_STRING} -r=true --api-cors-header='*' -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock ${DOCKER_OPTS}"
sed -i.bak '/^DOCKER_OPTS=/{h;s|=.*|=\"'"${DOCKER_OPTS}"'\"|};${x;/^$/{s||DOCKER_OPTS=\"'"${DOCKER_OPTS}"'\"|;H};x}' /etc/default/docker
Expand All @@ -85,9 +69,6 @@ usermod -a -G docker vagrant # Add vagrant user to the docker group
# Test docker
docker run --rm busybox echo All good

# Run our common setup
/hyperledger/scripts/provision/host.sh

# Set Go environment variables needed by other scripts
export GOPATH="/opt/gopath"
export GOROOT="/opt/go/"
Expand Down
1 change: 0 additions & 1 deletion images/base/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions images/base/Dockerfile.in

This file was deleted.

50 changes: 0 additions & 50 deletions images/base/Makefile

This file was deleted.

53 changes: 0 additions & 53 deletions images/base/README.md

This file was deleted.

34 changes: 0 additions & 34 deletions images/base/http/preseed.cfg

This file was deleted.

Loading

0 comments on commit ac8ab84

Please sign in to comment.