Skip to content
Snippets Groups Projects
Commit 742c007c authored by Silas Davis's avatar Silas Davis Committed by GitHub
Browse files

Merge pull request #318 from eris-ltd/feature-smaller-docker

utilize a common docker building paradigm across the stack
parents 528be6b0 565c6ccb
No related branches found
No related tags found
No related merge requests found
......@@ -5,4 +5,5 @@ build
Vagrantfile
README.md
circle.yml
api.md
\ No newline at end of file
api.md
vendor
\ No newline at end of file
# Pull base image.
FROM quay.io/eris/build
MAINTAINER Eris Industries <support@erisindustries.com>
MAINTAINER Monax <support@monax.io>
# Expose ports for 1337:eris-db API; 46656:tendermint-peer; 46657:tendermint-rpc
EXPOSE 1337
EXPOSE 46656
EXPOSE 46657
# Install eris-db, a go app that manages relationships
ENV TARGET eris-db
ENV REPO $GOPATH/src/github.com/eris-ltd/$TARGET
#-----------------------------------------------------------------------------
# install eris-db's dependencies
ADD ./glide.yaml $REPO/
ADD ./glide.lock $REPO/
WORKDIR $REPO
RUN glide install
# set the source code path and copy the repository in
ENV ERIS_DB_SRC_PATH $GOPATH/src/github.com/eris-ltd/eris-db
ADD glide.yaml $ERIS_DB_SRC_PATH/
ADD glide.lock $ERIS_DB_SRC_PATH/
# [csk] if we vendor the dependencies we should import them b4 the glide install, no?
COPY . $REPO/.
RUN cd $REPO/cmd/$TARGET && \
go build --ldflags '-extldflags "-static"' -o $INSTALL_BASE/$TARGET
# install glide for dependency management
RUN go get github.com/Masterminds/glide \
# install dependencies for eris-db with glide
&& cd $ERIS_DB_SRC_PATH \
&& glide install
#-----------------------------------------------------------------------------
# install mint-client [to be deprecated]
ENV ERIS_DB_MINT_REPO github.com/eris-ltd/mint-client
ENV ERIS_DB_MINT_SRC_PATH $GOPATH/src/$ERIS_DB_MINT_REPO
WORKDIR $ERIS_DB_MINT_SRC_PATH
RUN git clone --quiet https://$ERIS_DB_MINT_REPO . \
&& git checkout --quiet master \
&& go build -o $INSTALL_BASE/mintx ./mintx \
&& go build -o $INSTALL_BASE/mintconfig ./mintconfig \
&& go build -o $INSTALL_BASE/mintkey ./mintkey
# restrict build targets for re-evaluation
# && go build -o $INSTALL_BASE/mintdump ./mintdump \
# && go build -o $INSTALL_BASE/mintperms ./mintperms \
# && go build -o $INSTALL_BASE/mintunsafe ./mintunsafe \
# && go build -o $INSTALL_BASE/mintgen ./mintgen \
# && go build -o $INSTALL_BASE/mintsync ./mintsync
#-----------------------------------------------------------------------------
# install eris-db
# copy in the entire repo now (after dependencies installed)
COPY . $ERIS_DB_SRC_PATH
# build the main eris-db target
RUN cd $ERIS_DB_SRC_PATH/cmd/eris-db \
# statically link Alpine's c library to provide X-Linux buildability
# [csk] see -> https://github.com/eris-ltd/eris-pm/commit/e24c49c7ba1e62509377adacf8da650b51e84e6a
&& go build --ldflags '-extldflags "-static"' -o $INSTALL_BASE/eris-db \
# copy the start script for eris-db \
&& cp $ERIS_DB_SRC_PATH/bin/start_eris_db $INSTALL_BASE/erisdb-wrapper \
&& chmod 755 $INSTALL_BASE/erisdb-wrapper
#-----------------------------------------------------------------------------
# clean up [build container needs to be separated from shipped container]
RUN unset ERIS_DB_SRC_PATH \
&& unset ERIS_DB_MINT_SRC_PATH \
&& apk del --purge go git musl-dev \
&& rm -rf $GOPATH
# mount the data container on the eris directory
VOLUME $ERIS
WORKDIR $ERIS
CMD "erisdb-wrapper"
\ No newline at end of file
# build customizations start here
RUN cd $REPO/client/cmd/eris-client && \
go build --ldflags '-extldflags "-static"' -o $INSTALL_BASE/eris-client
FROM quay.io/eris/base:alpine
MAINTAINER Monax <support@monax.io>
ENV TARGET eris-db
# runtime customization start here
ADD ./eris-client $INSTALL_BASE
COPY ./bin/start_eris_db $INSTALL_BASE/erisdb-wrapper
# runtime customization end here
# Get the binary from the artifact in pwd
ADD ./$TARGET $INSTALL_BASE
RUN chmod +x --recursive $INSTALL_BASE
# Finalize
RUN chown --recursive $USER:$USER /home/$USER
VOLUME $ERIS
WORKDIR $ERIS
USER $USER
# runtime customization start here
# Expose ports for 1337:eris-db API; 46656:tendermint-peer; 46657:tendermint-rpc
EXPOSE 1337
EXPOSE 46656
EXPOSE 46657
CMD [ "eris-db", "serve" ]
......@@ -2,9 +2,9 @@
# ----------------------------------------------------------
# PURPOSE
# This is the build script for eris-db. It will build the
# tool into docker containers in a reliable and predicatable
# manner.
# This is the build script for the eris stack. It will
# build the tool into docker containers in a reliable and
# predicatable manner.
# ----------------------------------------------------------
# REQUIREMENTS
......@@ -17,34 +17,45 @@
# build_tool.sh
# ----------------------------------------------------------
# Set defaults
TARGET=eris-db
IMAGE=quay.io/eris/db
set -e
start=`pwd`
if [ "$CIRCLE_BRANCH" ]
if [ "$JENKINS_URL" ] || [ "$CIRCLE_BRANCH" ]
then
repo=`pwd`
REPO=`pwd`
CI="true"
else
base=github.com/eris-ltd/eris-db
repo=$GOPATH/src/$base
REPO=$GOPATH/src/github.com/eris-ltd/$TARGET
fi
branch=${CIRCLE_BRANCH:=master}
branch=${branch/-/_}
release_min=$(cat $repo/version/version.go | tail -n 1 | cut -d \ -f 4 | tr -d '"')
release_min=$(cat $REPO/version/version.go | tail -n 1 | cut -d \ -f 4 | tr -d '"')
release_maj=$(echo $release_min | cut -d . -f 1-2)
image_base=quay.io/eris/erisdb
# Build
docker build -t $IMAGE:build $REPO
docker run --rm --entrypoint cat $IMAGE:build /usr/local/bin/$TARGET > $REPO/$TARGET
docker run --rm --entrypoint cat $IMAGE:build /usr/local/bin/eris-client > $REPO/eris-client
docker build -t $IMAGE:$release_min -f Dockerfile.deploy $REPO
cd $repo
# Cleanup
rm $REPO/$TARGET
rm $REPO/eris-client
if [ "$CI" ]
then
docker rmi $IMAGE:build
fi
# Extra Tags
if [[ "$branch" = "master" ]]
then
docker build -t $image_base:latest $repo
docker tag $image_base:latest $image_base:$release_maj
docker tag $image_base:latest $image_base:$release_min
else
docker build -t $image_base:$release_min $repo
docker tag -f $IMAGE:$release_min $IMAGE:$release_maj
docker tag -f $IMAGE:$release_min $IMAGE:latest
fi
if [ "$CIRCLE_BRANCH" ]
then
docker tag -f $IMAGE:$release_min $IMAGE:latest
fi
test_exit=$?
cd $start
exit $test_exit
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment