Improve Docker build process - #36
Conversation
|
|
||
| WORKDIR / | ||
| RUN apt-get update | ||
| RUN apt-get install -y llvm g++ libgmp-dev libssl-dev git-core build-essential |
There was a problem hiding this comment.
I appreciate that this makes the image smaller butttt we need it to run the library behind DKG?
There was a problem hiding this comment.
It's a DLL that's required by dfinity/bn
There was a problem hiding this comment.
The Alpine image includes dfinity/bn. Things are done a bit differently b/c the smaller, underlying operating system is different. Please see comments below for details.
There was a problem hiding this comment.
I've used Alpine before. You've snipped a dynamic lib written in C++ that bn needed to execute properly
There was a problem hiding this comment.
Hm, going to give this another look in the morning. Not sure how this could work without setting the LD path but maybe Alpine has a different default
There was a problem hiding this comment.
Ah, I see- you moved it to one RUN line. That means anytime we update the bn library we need to re-run all other dep installs. It shouldn't save space on the image or build time but it will lead to more re-builds
|
|
||
| ENV GOPATH=/go \ | ||
| GOBIN=/go/bin \ | ||
| APP_REPO_DIR=/go/src/keep-network/keep-client \ |
|
|
||
| ENV LD_LIBRARY_PATH=/usr/local/lib/ | ||
| ENTRYPOINT ["./keep-client"] | ||
| # docker caches more when using CMD [] resulting in a faster build. |
| @@ -0,0 +1,31 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
I feel like I'm missing the point of this file? Is it all just to pull some things out of the docker build? Does CI still properly build the client?
There was a problem hiding this comment.
The only thing that is missing is the following ENV variable setting...
ENV LD_LIBRARY_PATH=/usr/local/lib/
... It's purpose was/is not obvious to me.
Some package names are different (between the golang:1.9.2, which I think is based on the Debian image) and the golang:1.9.4-alpine3.7 image.
These two lines of coded in golang:1.9.2 ...
RUN apt-get update
RUN apt-get install -y llvm g++ libgmp-dev libssl-dev git-core build-essential
... are equivalent to this part of this one line in the golang:1.9.4-alpine3.7 image:
RUN apk add --update --no-cache \
bash \
clang \
g++ \
git \
gmp \
gmp-dev \
libgmpxx \
libstdc++ \
llvm \
make \
openssl \
openssl-dev . . .
For example, the Alpine image does not have a build-essential. Instead, we must explicitly include the bash, clang, git, gmp, gmp-dev, and make packages.
The following command can run the container (same for both images) and produce the same output:
$ docker run --rm --name keep-client --detach keep-client Dockerfile .
4b62b59f4ce4498c435fb92dfc3547b105a39b2c3409126a9438738378c74127
I've not yet been shown the CI process here, so I can't speak to what's going on there, but I'd image that very little would need to be tweaked to make the Alpine-based image run properly.
The bottom line is the Alpine image solution is half the size and runs twice as fast and produces the same binary. (Both have the same ENTRYPOINT ["keep-client"] line in the Dockerfile which means their containers run the same binary.)
There was a problem hiding this comment.
Here's the full log results from the FROM golang:1.9.2 image build:
~/dev/go/keep-core-master/src/github.com/keep-network/keep-core $ time docker build -t "$IMG" -f "$DOCKERFILE" .
Sending build context to Docker daemon 4.89MB
Step 1/17 : FROM golang:1.9.2
1.9.2: Pulling from library/golang
723254a2c089: Pull complete
abe15a44e12f: Pull complete
409a28e3cc3d: Pull complete
503166935590: Pull complete
abe52c89597f: Pull complete
ce145c5cf4da: Pull complete
96e333289084: Pull complete
39cd5f38ffb8: Pull complete
Digest: sha256:947826b5b6bc42f6f25c8fae9fe89d5e2bf18ac87264856742c3baebb150ea9f
Status: Downloaded newer image for golang:1.9.2
---> 138bd936fa29
Step 2/17 : WORKDIR /
Removing intermediate container 966a01d18cce
---> 150926103bef
Step 3/17 : RUN apt-get update
---> Running in bf070c9cee64
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://security.debian.org stretch/updates InRelease [63.0 kB]
Get:3 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:4 http://deb.debian.org/debian stretch Release [118 kB]
Get:5 http://deb.debian.org/debian stretch Release.gpg [2434 B]
Get:6 http://security.debian.org stretch/updates/main amd64 Packages [377 kB]
Get:7 http://deb.debian.org/debian stretch-updates/main amd64 Packages [8431 B]
Get:8 http://deb.debian.org/debian stretch/main amd64 Packages [9531 kB]
Fetched 10.2 MB in 2s (4517 kB/s)
Reading package lists...
Removing intermediate container bf070c9cee64
---> 93311d4566bc
Step 4/17 : RUN apt-get install -y llvm g++ libgmp-dev libssl-dev git-core build-essential
---> Running in 631cd645b6cd
Reading package lists...
Building dependency tree...
Reading state information...
g++ is already the newest version (4:6.3.0-4).
The following additional packages will be installed:
binfmt-support bzip2 dpkg-dev fakeroot libalgorithm-diff-perl
libalgorithm-diff-xs-perl libalgorithm-merge-perl libfakeroot libffi-dev
libgmpxx4ldbl libjsoncpp1 libllvm3.8 libpipeline1 libssl-doc libtinfo-dev
llvm-3.8 llvm-3.8-dev llvm-3.8-runtime llvm-runtime patch xz-utils
Suggested packages:
bzip2-doc debian-keyring gmp-doc libgmp10-doc libmpfr-dev llvm-3.8-doc ed
diffutils-doc
The following NEW packages will be installed:
binfmt-support build-essential bzip2 dpkg-dev fakeroot git-core
libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
libfakeroot libffi-dev libgmp-dev libgmpxx4ldbl libjsoncpp1 libllvm3.8
libpipeline1 libssl-dev libssl-doc libtinfo-dev llvm llvm-3.8 llvm-3.8-dev
llvm-3.8-runtime llvm-runtime patch xz-utils
0 upgraded, 26 newly installed, 0 to remove and 8 not upgraded.
Need to get 34.5 MB of archives.
After this operation, 175 MB of additional disk space will be used.
Get:1 http://deb.debian.org/debian stretch/main amd64 libpipeline1 amd64 1.4.1-2 [27.6 kB]
Get:2 http://deb.debian.org/debian stretch/main amd64 bzip2 amd64 1.0.6-8.1 [47.5 kB]
Get:3 http://deb.debian.org/debian stretch/main amd64 xz-utils amd64 5.2.2-1.2+b1 [266 kB]
Get:4 http://deb.debian.org/debian stretch/main amd64 binfmt-support amd64 2.1.6-2 [59.5 kB]
Get:5 http://deb.debian.org/debian stretch/main amd64 patch amd64 2.7.5-1+b2 [112 kB]
Get:6 http://deb.debian.org/debian stretch/main amd64 dpkg-dev all 1.18.24 [1592 kB]
Get:7 http://deb.debian.org/debian stretch/main amd64 build-essential amd64 12.3 [7346 B]
Get:8 http://deb.debian.org/debian stretch/main amd64 libfakeroot amd64 1.21-3.1 [45.7 kB]
Get:9 http://deb.debian.org/debian stretch/main amd64 fakeroot amd64 1.21-3.1 [85.6 kB]
Get:10 http://deb.debian.org/debian stretch/main amd64 git-core all 1:2.11.0-3+deb9u2 [1410 B]
Get:11 http://deb.debian.org/debian stretch/main amd64 libalgorithm-diff-perl all 1.19.03-1 [48.7 kB]
Get:12 http://deb.debian.org/debian stretch/main amd64 libalgorithm-diff-xs-perl amd64 0.04-4+b2 [11.6 kB]
Get:13 http://deb.debian.org/debian stretch/main amd64 libalgorithm-merge-perl all 0.08-3 [12.7 kB]
Get:14 http://deb.debian.org/debian stretch/main amd64 libffi-dev amd64 3.2.1-6 [161 kB]
Get:15 http://deb.debian.org/debian stretch/main amd64 libgmpxx4ldbl amd64 2:6.1.2+dfsg-1 [22.2 kB]
Get:16 http://deb.debian.org/debian stretch/main amd64 libgmp-dev amd64 2:6.1.2+dfsg-1 [631 kB]
Get:17 http://deb.debian.org/debian stretch/main amd64 libllvm3.8 amd64 1:3.8.1-24 [10.4 MB]
Get:18 http://deb.debian.org/debian stretch/main amd64 libssl-dev amd64 1.1.0f-3+deb9u1 [1575 kB]
Get:19 http://deb.debian.org/debian stretch/main amd64 libssl-doc all 1.1.0f-3+deb9u1 [1456 kB]
Get:20 http://deb.debian.org/debian stretch/main amd64 libtinfo-dev amd64 6.0+20161126-1+deb9u1 [79.2 kB]
Get:21 http://deb.debian.org/debian stretch/main amd64 llvm-3.8-runtime amd64 1:3.8.1-24 [87.9 kB]
Get:22 http://deb.debian.org/debian stretch/main amd64 llvm-runtime amd64 1:3.8-36 [5366 B]
Get:23 http://deb.debian.org/debian stretch/main amd64 llvm-3.8 amd64 1:3.8.1-24 [1548 kB]
Get:24 http://deb.debian.org/debian stretch/main amd64 llvm amd64 1:3.8-36 [7136 B]
Get:25 http://deb.debian.org/debian stretch/main amd64 libjsoncpp1 amd64 1.7.4-3 [75.6 kB]
Get:26 http://deb.debian.org/debian stretch/main amd64 llvm-3.8-dev amd64 1:3.8.1-24 [16.1 MB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 34.5 MB in 3s (8736 kB/s)
Selecting previously unselected package libpipeline1:amd64.
(Reading database ... 15050 files and directories currently installed.)
Preparing to unpack .../00-libpipeline1_1.4.1-2_amd64.deb ...
Unpacking libpipeline1:amd64 (1.4.1-2) ...
Selecting previously unselected package bzip2.
Preparing to unpack .../01-bzip2_1.0.6-8.1_amd64.deb ...
Unpacking bzip2 (1.0.6-8.1) ...
Selecting previously unselected package xz-utils.
Preparing to unpack .../02-xz-utils_5.2.2-1.2+b1_amd64.deb ...
Unpacking xz-utils (5.2.2-1.2+b1) ...
Selecting previously unselected package binfmt-support.
Preparing to unpack .../03-binfmt-support_2.1.6-2_amd64.deb ...
Unpacking binfmt-support (2.1.6-2) ...
Selecting previously unselected package patch.
Preparing to unpack .../04-patch_2.7.5-1+b2_amd64.deb ...
Unpacking patch (2.7.5-1+b2) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../05-dpkg-dev_1.18.24_all.deb ...
Unpacking dpkg-dev (1.18.24) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../06-build-essential_12.3_amd64.deb ...
Unpacking build-essential (12.3) ...
Selecting previously unselected package libfakeroot:amd64.
Preparing to unpack .../07-libfakeroot_1.21-3.1_amd64.deb ...
Unpacking libfakeroot:amd64 (1.21-3.1) ...
Selecting previously unselected package fakeroot.
Preparing to unpack .../08-fakeroot_1.21-3.1_amd64.deb ...
Unpacking fakeroot (1.21-3.1) ...
Selecting previously unselected package git-core.
Preparing to unpack .../09-git-core_1%3a2.11.0-3+deb9u2_all.deb ...
Unpacking git-core (1:2.11.0-3+deb9u2) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../10-libalgorithm-diff-perl_1.19.03-1_all.deb ...
Unpacking libalgorithm-diff-perl (1.19.03-1) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../11-libalgorithm-diff-xs-perl_0.04-4+b2_amd64.deb ...
Unpacking libalgorithm-diff-xs-perl (0.04-4+b2) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../12-libalgorithm-merge-perl_0.08-3_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-3) ...
Selecting previously unselected package libffi-dev:amd64.
Preparing to unpack .../13-libffi-dev_3.2.1-6_amd64.deb ...
Unpacking libffi-dev:amd64 (3.2.1-6) ...
Selecting previously unselected package libgmpxx4ldbl:amd64.
Preparing to unpack .../14-libgmpxx4ldbl_2%3a6.1.2+dfsg-1_amd64.deb ...
Unpacking libgmpxx4ldbl:amd64 (2:6.1.2+dfsg-1) ...
Selecting previously unselected package libgmp-dev:amd64.
Preparing to unpack .../15-libgmp-dev_2%3a6.1.2+dfsg-1_amd64.deb ...
Unpacking libgmp-dev:amd64 (2:6.1.2+dfsg-1) ...
Selecting previously unselected package libllvm3.8:amd64.
Preparing to unpack .../16-libllvm3.8_1%3a3.8.1-24_amd64.deb ...
Unpacking libllvm3.8:amd64 (1:3.8.1-24) ...
Selecting previously unselected package libssl-dev:amd64.
Preparing to unpack .../17-libssl-dev_1.1.0f-3+deb9u1_amd64.deb ...
Unpacking libssl-dev:amd64 (1.1.0f-3+deb9u1) ...
Selecting previously unselected package libssl-doc.
Preparing to unpack .../18-libssl-doc_1.1.0f-3+deb9u1_all.deb ...
Unpacking libssl-doc (1.1.0f-3+deb9u1) ...
Selecting previously unselected package libtinfo-dev:amd64.
Preparing to unpack .../19-libtinfo-dev_6.0+20161126-1+deb9u1_amd64.deb ...
Unpacking libtinfo-dev:amd64 (6.0+20161126-1+deb9u1) ...
Selecting previously unselected package llvm-3.8-runtime.
Preparing to unpack .../20-llvm-3.8-runtime_1%3a3.8.1-24_amd64.deb ...
Unpacking llvm-3.8-runtime (1:3.8.1-24) ...
Selecting previously unselected package llvm-runtime.
Preparing to unpack .../21-llvm-runtime_1%3a3.8-36_amd64.deb ...
Unpacking llvm-runtime (1:3.8-36) ...
Selecting previously unselected package llvm-3.8.
Preparing to unpack .../22-llvm-3.8_1%3a3.8.1-24_amd64.deb ...
Unpacking llvm-3.8 (1:3.8.1-24) ...
Selecting previously unselected package llvm.
Preparing to unpack .../23-llvm_1%3a3.8-36_amd64.deb ...
Unpacking llvm (1:3.8-36) ...
Selecting previously unselected package libjsoncpp1:amd64.
Preparing to unpack .../24-libjsoncpp1_1.7.4-3_amd64.deb ...
Unpacking libjsoncpp1:amd64 (1.7.4-3) ...
Selecting previously unselected package llvm-3.8-dev.
Preparing to unpack .../25-llvm-3.8-dev_1%3a3.8.1-24_amd64.deb ...
Unpacking llvm-3.8-dev (1:3.8.1-24) ...
Setting up libllvm3.8:amd64 (1:3.8.1-24) ...
Setting up libssl-dev:amd64 (1.1.0f-3+deb9u1) ...
Setting up libtinfo-dev:amd64 (6.0+20161126-1+deb9u1) ...
Setting up libffi-dev:amd64 (3.2.1-6) ...
Setting up libpipeline1:amd64 (1.4.1-2) ...
Setting up bzip2 (1.0.6-8.1) ...
Setting up patch (2.7.5-1+b2) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Setting up xz-utils (5.2.2-1.2+b1) ...
update-alternatives: using /usr/bin/xz to provide /usr/bin/lzma (lzma) in auto mode
Setting up libfakeroot:amd64 (1.21-3.1) ...
Setting up libalgorithm-diff-perl (1.19.03-1) ...
Setting up libssl-doc (1.1.0f-3+deb9u1) ...
Setting up libgmpxx4ldbl:amd64 (2:6.1.2+dfsg-1) ...
Setting up git-core (1:2.11.0-3+deb9u2) ...
Setting up libjsoncpp1:amd64 (1.7.4-3) ...
Setting up libgmp-dev:amd64 (2:6.1.2+dfsg-1) ...
Setting up binfmt-support (2.1.6-2) ...
mount: permission denied
update-binfmts: warning: Couldn't mount the binfmt_misc filesystem on /proc/sys/fs/binfmt_misc.
mount: permission denied
update-binfmts: warning: Couldn't mount the binfmt_misc filesystem on /proc/sys/fs/binfmt_misc.
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of start.
Setting up fakeroot (1.21-3.1) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up dpkg-dev (1.18.24) ...
Setting up libalgorithm-diff-xs-perl (0.04-4+b2) ...
Setting up llvm-3.8-runtime (1:3.8.1-24) ...
mount: permission denied
update-binfmts: warning: Couldn't mount the binfmt_misc filesystem on /proc/sys/fs/binfmt_misc.
Setting up llvm-3.8 (1:3.8.1-24) ...
Setting up build-essential (12.3) ...
Setting up llvm-3.8-dev (1:3.8.1-24) ...
Setting up llvm-runtime (1:3.8-36) ...
Setting up llvm (1:3.8-36) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Removing intermediate container 631cd645b6cd
---> dc35392daa01
Step 5/17 : ENV BN_VERSION=d1a44d2f242692601b3e150b59044ab82f265b65
---> Running in d5bdcdd490dc
Removing intermediate container d5bdcdd490dc
---> d12026ae8aec
Step 6/17 : RUN git clone https://github.com/keep-network/bn
---> Running in 87a60dc3d88b
Cloning into 'bn'...
Removing intermediate container 87a60dc3d88b
---> 9f7fa874a4d4
Step 7/17 : WORKDIR /bn/
Removing intermediate container 56ed51f4be64
---> 961e6f59e427
Step 8/17 : RUN git reset --hard $BN_VERSION
---> Running in 24e10c98825e
HEAD is now at d1a44d2 Merge pull request #13 from katrielalex/patch-1
Removing intermediate container 24e10c98825e
---> 99bee3a2ef73
Step 9/17 : RUN make && make install
---> Running in 55e8390ef02a
make -C mcl UPDATE_ASM=1 lib/libmcl.a CFLAGS_USER=-std=c++11 MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/mcl'
g++ -o src/gen src/gen.cpp -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1 -O0
src/gen -f src/func.list > src/base64.ll
opt -O3 -o - src/base64.ll -march=x86-64 | llc -O3 -o src/asm/x86-64.s -march=x86-64 -relocation-model=pic -pre-RA-sched=list-ilp -max-sched-reorder=128
g++ -c src/asm/x86-64.s -o obj/x86-64.o -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1
src/gen -f src/func.list -s bmi2 > src/base64.bmi2.ll
opt -O3 -o - src/base64.bmi2.ll -march=x86-64 | llc -O3 -o src/asm/x86-64.bmi2.s -march=x86-64 -relocation-model=pic -pre-RA-sched=list-ilp -max-sched-reorder=128 -mattr=bmi2
g++ -c src/asm/x86-64.bmi2.s -o obj/x86-64.bmi2.o -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1
g++ -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1 -c src/fp.cpp -o obj/fp.o -MMD -MP -MF obj/fp.d
ar r lib/libmcl.a obj/fp.o obj/x86-64.o obj/x86-64.bmi2.o
ar: creating lib/libmcl.a
make[1]: Leaving directory '/bn/mcl'
make -C bls MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/bls'
g++ -o libbls384.so src/bls_c.cpp -shared -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -std=c++11 -I../mcl/include -I./include -DMCL_MAX_BIT_SIZE=384 -D"MCLBN_FP_UNIT_SIZE=6" ../mcl/lib/libmcl.a -lgmpxx -lgmp -lcrypto
make[1]: Leaving directory '/bn/bls'
make -C mcl UPDATE_ASM=1 lib/libmcl.a CFLAGS_USER=-std=c++11 MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/mcl'
make[1]: 'lib/libmcl.a' is up to date.
make[1]: Leaving directory '/bn/mcl'
make -C bls MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/bls'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/bn/bls'
mkdir -p /usr/local/lib
cp -a bls/libbls384.so /usr/local/lib
mkdir -p /usr/local/include/bls
cp -a bls/include/bls/bls.h /usr/local/include/bls
mkdir -p /usr/local/include/mcl
cp -a mcl/include/mcl/bn.h /usr/local/include/mcl
Removing intermediate container 55e8390ef02a
---> ca6988aab23a
Step 10/17 : WORKDIR /go/src/keep-network/
Removing intermediate container 4277ec8f3ae0
---> 063ce5c90dbd
Step 11/17 : RUN go get -u github.com/golang/dep/cmd/dep
---> Running in 78cde604ec8b
Removing intermediate container 78cde604ec8b
---> dfb374552785
Step 12/17 : COPY ./go/Gopkg.toml ./go/Gopkg.lock ./
---> 88373285ccc4
Step 13/17 : RUN dep ensure --vendor-only
---> Running in 69bb854c4c87
Removing intermediate container 69bb854c4c87
---> 6e1ac0e008b6
Step 14/17 : COPY ./go/ ./
---> 1ecd9a8e6a36
Step 15/17 : RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o keep-client .
---> Running in f1366d238319
Removing intermediate container f1366d238319
---> 4d257d85e689
Step 16/17 : ENV LD_LIBRARY_PATH=/usr/local/lib/
---> Running in b15da9824f58
Removing intermediate container b15da9824f58
---> a8ffc70d4eda
Step 17/17 : ENTRYPOINT ["./keep-client"]
---> Running in 45425703ccba
Removing intermediate container 45425703ccba
---> e684bd7d4c73
Successfully built e684bd7d4c73
Successfully tagged keep-client:latest
real 2m56.026s
user 0m0.325s
sys 0m0.283s
Steps 6-9 show the BN (Barreto-Naehrig curve implementation and BLS) build results:
Step 6/17 : RUN git clone https://github.com/keep-network/bn
---> Running in 87a60dc3d88b
Cloning into 'bn'...
Removing intermediate container 87a60dc3d88b
---> 9f7fa874a4d4
Step 7/17 : WORKDIR /bn/
Removing intermediate container 56ed51f4be64
---> 961e6f59e427
Step 8/17 : RUN git reset --hard $BN_VERSION
---> Running in 24e10c98825e
HEAD is now at d1a44d2 Merge pull request #13 from katrielalex/patch-1
Removing intermediate container 24e10c98825e
---> 99bee3a2ef73
Step 9/17 : RUN make && make install
---> Running in 55e8390ef02a
make -C mcl UPDATE_ASM=1 lib/libmcl.a CFLAGS_USER=-std=c++11 MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/mcl'
g++ -o src/gen src/gen.cpp -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1 -O0
src/gen -f src/func.list > src/base64.ll
opt -O3 -o - src/base64.ll -march=x86-64 | llc -O3 -o src/asm/x86-64.s -march=x86-64 -relocation-model=pic -pre-RA-sched=list-ilp -max-sched-reorder=128
g++ -c src/asm/x86-64.s -o obj/x86-64.o -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1
src/gen -f src/func.list -s bmi2 > src/base64.bmi2.ll
opt -O3 -o - src/base64.bmi2.ll -march=x86-64 | llc -O3 -o src/asm/x86-64.bmi2.s -march=x86-64 -relocation-model=pic -pre-RA-sched=list-ilp -max-sched-reorder=128 -mattr=bmi2
g++ -c src/asm/x86-64.bmi2.s -o obj/x86-64.bmi2.o -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1
g++ -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1 -c src/fp.cpp -o obj/fp.o -MMD -MP -MF obj/fp.d
ar r lib/libmcl.a obj/fp.o obj/x86-64.o obj/x86-64.bmi2.o
ar: creating lib/libmcl.a
make[1]: Leaving directory '/bn/mcl'
make -C bls MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/bls'
g++ -o libbls384.so src/bls_c.cpp -shared -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -std=c++11 -I../mcl/include -I./include -DMCL_MAX_BIT_SIZE=384 -D"MCLBN_FP_UNIT_SIZE=6" ../mcl/lib/libmcl.a -lgmpxx -lgmp -lcrypto
make[1]: Leaving directory '/bn/bls'
make -C mcl UPDATE_ASM=1 lib/libmcl.a CFLAGS_USER=-std=c++11 MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/mcl'
make[1]: 'lib/libmcl.a' is up to date.
make[1]: Leaving directory '/bn/mcl'
make -C bls MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/bls'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/bn/bls'
mkdir -p /usr/local/lib
cp -a bls/libbls384.so /usr/local/lib
mkdir -p /usr/local/include/bls
cp -a bls/include/bls/bls.h /usr/local/include/bls
mkdir -p /usr/local/include/mcl
cp -a mcl/include/mcl/bn.h /usr/local/include/mcl
Removing intermediate container 55e8390ef02a
---> ca6988aab23a
There was a problem hiding this comment.
Below, is the full build results for the golang:1.9.4-alpine3.7 build:
~/dev/go/keep-core-client/src/github.com/keep-network/keep-core $ time docker build -t keep-client -f Dockerfile .
Sending build context to Docker daemon 5.99MB
Step 1/9 : FROM golang:1.9.4-alpine3.7
1.9.4-alpine3.7: Pulling from library/golang
ff3a5c916c92: Pull complete
f32d2ea73378: Pull complete
7e338747c3ca: Pull complete
3a75aa9cb0c3: Pull complete
7a7cfbabfc25: Pull complete
43b7df8cdce7: Pull complete
Digest: sha256:e54935a7ef352167b0c90d1de3540d3646f3f12579a875cac2e3ad44062fbc7d
Status: Downloaded newer image for golang:1.9.4-alpine3.7
---> fb6e10bf973b
Step 2/9 : ENV GOPATH=/go GOBIN=/go/bin APP_REPO_DIR=/go/src/keep-network/keep-client APP_NAME=keep-client
---> Running in 713706e19a08
Removing intermediate container 713706e19a08
---> e9a6ac26d742
Step 3/9 : RUN apk add --update --no-cache bash clang g++ git gmp gmp-dev libgmpxx libstdc++ llvm make openssl openssl-dev && git clone https://github.com/dfinity/bn /bn && cd /bn && make install && make && rm -rf /bn && mkdir -p /go/src && rm -rf /var/cache/apk && mkdir /var/cache/apk && rm -rf /usr/share/man && apk del git make clang llvm && mkdir -p $APP_REPO_DIR
---> Running in 0740f1d5b1d7
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
(1/38) Installing pkgconf (1.3.10-r0)
(2/38) Installing ncurses-terminfo-base (6.0_p20171125-r0)
(3/38) Installing ncurses-terminfo (6.0_p20171125-r0)
(4/38) Installing ncurses-libs (6.0_p20171125-r0)
(5/38) Installing readline (7.0.003-r0)
(6/38) Installing bash (4.4.19-r1)
Executing bash-4.4.19-r1.post-install
(7/38) Installing libgcc (6.4.0-r5)
(8/38) Installing libstdc++ (6.4.0-r5)
(9/38) Installing clang-libs (5.0.0-r0)
(10/38) Installing libxml2 (2.9.7-r0)
(11/38) Installing clang (5.0.0-r0)
(12/38) Installing binutils-libs (2.28-r3)
(13/38) Installing binutils (2.28-r3)
(14/38) Installing gmp (6.1.2-r1)
(15/38) Installing isl (0.18-r0)
(16/38) Installing libgomp (6.4.0-r5)
(17/38) Installing libatomic (6.4.0-r5)
(18/38) Installing mpfr3 (3.1.5-r1)
(19/38) Installing mpc1 (1.0.3-r1)
(20/38) Installing gcc (6.4.0-r5)
(21/38) Installing musl-dev (1.1.18-r3)
(22/38) Installing libc-dev (0.7.1-r0)
(23/38) Installing g++ (6.4.0-r5)
(24/38) Installing libcurl (7.58.0-r0)
(25/38) Installing expat (2.2.5-r0)
(26/38) Installing pcre2 (10.30-r0)
(27/38) Installing git (2.15.0-r1)
(28/38) Installing libgmpxx (6.1.2-r1)
(29/38) Installing gmp-dev (6.1.2-r1)
(30/38) Installing libffi (3.2.1-r4)
(31/38) Installing llvm5-libs (5.0.0-r0)
(32/38) Installing llvm5 (5.0.0-r0)
(33/38) Installing make (4.2.1-r0)
(34/38) Installing libcrypto1.0 (1.0.2n-r0)
(35/38) Installing libssl1.0 (1.0.2n-r0)
(36/38) Installing openssl (1.0.2n-r0)
(37/38) Installing zlib-dev (1.2.11-r1)
(38/38) Installing openssl-dev (1.0.2n-r0)
Executing busybox-1.27.2-r7.trigger
Executing ca-certificates-20171114-r0.trigger
OK: 429 MiB in 50 packages
Cloning into '/bn'...
make -C mcl UPDATE_ASM=1 lib/libmcl.a CFLAGS_USER=-std=c++11 MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/mcl'
g++ -o src/gen src/gen.cpp -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1 -O0
src/gen -f src/func.list > src/base64.ll
opt -O3 -o - src/base64.ll -march=x86-64 | llc -O3 -o src/asm/x86-64.s -march=x86-64 -relocation-model=pic -pre-RA-sched=list-ilp -max-sched-reorder=128
g++ -c src/asm/x86-64.s -o obj/x86-64.o -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1
src/gen -f src/func.list -s bmi2 > src/base64.bmi2.ll
opt -O3 -o - src/base64.bmi2.ll -march=x86-64 | llc -O3 -o src/asm/x86-64.bmi2.s -march=x86-64 -relocation-model=pic -pre-RA-sched=list-ilp -max-sched-reorder=128 -mattr=bmi2
g++ -c src/asm/x86-64.bmi2.s -o obj/x86-64.bmi2.o -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1
g++ -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1 -c src/fp.cpp -o obj/fp.o -MMD -MP -MF obj/fp.d
ar r lib/libmcl.a obj/fp.o obj/x86-64.o obj/x86-64.bmi2.o
ar: creating lib/libmcl.a
make[1]: Leaving directory '/bn/mcl'
make -C bls MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/bls'
g++ -o libbls384.so src/bls_c.cpp -shared -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -std=c++11 -I../mcl/include -I./include -DMCL_MAX_BIT_SIZE=384 -D"MCLBN_FP_UNIT_SIZE=6" ../mcl/lib/libmcl.a -lgmpxx -lgmp -lcrypto
make[1]: Leaving directory '/bn/bls'
mkdir -p /usr/local/lib
cp -a mcl/lib/libmcl.a /usr/local/lib
cp -a bls/libbls384.so /usr/local/lib
mkdir -p /usr/local/include/bls
cp -a bls/include/bls/bls.h /usr/local/include/bls
mkdir -p /usr/local/include/mcl
cp -a mcl/include/mcl/bn.h /usr/local/include/mcl
make -C mcl UPDATE_ASM=1 lib/libmcl.a CFLAGS_USER=-std=c++11 MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/mcl'
make[1]: 'lib/libmcl.a' is up to date.
make[1]: Leaving directory '/bn/mcl'
make -C bls MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/bls'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/bn/bls'
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
(1/11) Purging clang (5.0.0-r0)
(2/11) Purging git (2.15.0-r1)
(3/11) Purging llvm5 (5.0.0-r0)
(4/11) Purging make (4.2.1-r0)
(5/11) Purging clang-libs (5.0.0-r0)
(6/11) Purging libxml2 (2.9.7-r0)
(7/11) Purging libcurl (7.58.0-r0)
(8/11) Purging expat (2.2.5-r0)
(9/11) Purging pcre2 (10.30-r0)
(10/11) Purging llvm5-libs (5.0.0-r0)
(11/11) Purging libffi (3.2.1-r4)
Executing busybox-1.27.2-r7.trigger
OK: 191 MiB in 39 packages
Removing intermediate container 0740f1d5b1d7
---> ecf6476859ff
Step 4/9 : ENV BN_VERSION=d1a44d2f242692601b3e150b59044ab82f265b65
---> Running in 3c63f26ed767
Removing intermediate container 3c63f26ed767
---> 1bd505d414c7
Step 5/9 : COPY ./go $APP_REPO_DIR
---> e680734512e8
Step 6/9 : WORKDIR $APP_REPO_DIR
Removing intermediate container 57e268fd9633
---> 41e6ae516bad
Step 7/9 : RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o $APP_NAME . && mv $APP_NAME /usr/local/bin && rm -rf $APP_REPO_DIR
---> Running in 397f1e821afe
Removing intermediate container 397f1e821afe
---> 856da6ad4e2f
Step 8/9 : ENTRYPOINT ["keep-client"]
---> Running in 4d18ce8dbc25
Removing intermediate container 4d18ce8dbc25
---> b469bb4eaf05
Step 9/9 : CMD []
---> Running in 2d62f5c1c142
Removing intermediate container 2d62f5c1c142
---> 34ec557fa686
Successfully built 34ec557fa686
Successfully tagged keep-client:latest
real 1m37.119s
user 0m0.232s
sys 0m0.280s
~/dev/go/keep-core-client/src/github.com/keep-network/keep-core $ dm-list-images
REPOSITORY TAG IMAGE ID CREATED SIZE
keep-client latest 34ec557fa686 25 seconds ago 458MB
golang 1.9.4-alpine3.7 fb6e10bf973b 6 days ago 269MB
~/dev/go/keep-core-client/src/github.com/keep-network/keep-core $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
keep-client latest 34ec557fa686 45 seconds ago 458MB
golang 1.9.4-alpine3.7 fb6e10bf973b 6 days ago 269MB
~/dev/go/keep-core-client/src/github.com/keep-network/keep-core $ me go/beacon/beacon.go
~/dev/go/keep-core-client/src/github.com/keep-network/keep-core $ me go/main.go
~/dev/go/keep-core-client/src/github.com/keep-network/keep-core $ time docker build -t keep-client -f Dockerfile .
Sending build context to Docker daemon 5.99MB
Step 1/9 : FROM golang:1.9.4-alpine3.7
---> fb6e10bf973b
Step 2/9 : ENV GOPATH=/go GOBIN=/go/bin APP_REPO_DIR=/go/src/keep-network/keep-client APP_NAME=keep-client
---> Using cache
---> e9a6ac26d742
Step 3/9 : RUN apk add --update --no-cache bash clang g++ git gmp gmp-dev libgmpxx libstdc++ llvm make openssl openssl-dev && git clone https://github.com/dfinity/bn /bn && cd /bn && make install && make && rm -rf /bn && mkdir -p /go/src && rm -rf /var/cache/apk && mkdir /var/cache/apk && rm -rf /usr/share/man && apk del git make clang llvm && mkdir -p $APP_REPO_DIR
---> Using cache
---> ecf6476859ff
Step 4/9 : ENV BN_VERSION=d1a44d2f242692601b3e150b59044ab82f265b65
---> Using cache
---> 1bd505d414c7
Step 5/9 : COPY ./go $APP_REPO_DIR
---> 5bef17a295cc
Step 6/9 : WORKDIR $APP_REPO_DIR
Removing intermediate container f91aeab23203
---> db92b084ff1d
Step 7/9 : RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o $APP_NAME . && mv $APP_NAME /usr/local/bin && rm -rf $APP_REPO_DIR
---> Running in 64e6d893f93f
Removing intermediate container 64e6d893f93f
---> 1fbaaedc3027
Step 8/9 : ENTRYPOINT ["keep-client"]
---> Running in ae7e0ac1ae9a
Removing intermediate container ae7e0ac1ae9a
---> 8e1ec949b5a6
Step 9/9 : CMD []
---> Running in e2ba01392e5e
Removing intermediate container e2ba01392e5e
---> 172851c2dc78
Successfully built 172851c2dc78
Successfully tagged keep-client:latest
real 0m7.363s
user 0m0.144s
sys 0m0.206s
There was a problem hiding this comment.
Instead of taking 4 steps to build BN (Barreto-Naehrig curve implementation and BLS, from https://github.com/keep-network/bn) it takes 1 step.
The BN_VERSION variable is set below. In case it needs to change the rebuild of the image will be very fast. ( If we know that it will never change, we can include it in the earlier ENV statement.)
ENV BN_VERSION=d1a44d2f242692601b3e150b59044ab82f265b65
Step 3/9 : RUN apk add --update --no-cache bash clang g++ git gmp gmp-dev libgmpxx libstdc++ llvm make openssl openssl-dev && git clone https://github.com/dfinity/bn /bn && cd /bn && make install && make && rm -rf /bn && mkdir -p /go/src && rm -rf /var/cache/apk && mkdir /var/cache/apk && rm -rf /usr/share/man && apk del git make clang llvm && mkdir -p $APP_REPO_DIR
---> Running in 0740f1d5b1d7
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
(1/38) Installing pkgconf (1.3.10-r0)
(2/38) Installing ncurses-terminfo-base (6.0_p20171125-r0)
(3/38) Installing ncurses-terminfo (6.0_p20171125-r0)
(4/38) Installing ncurses-libs (6.0_p20171125-r0)
(5/38) Installing readline (7.0.003-r0)
(6/38) Installing bash (4.4.19-r1)
Executing bash-4.4.19-r1.post-install
(7/38) Installing libgcc (6.4.0-r5)
(8/38) Installing libstdc++ (6.4.0-r5)
(9/38) Installing clang-libs (5.0.0-r0)
(10/38) Installing libxml2 (2.9.7-r0)
(11/38) Installing clang (5.0.0-r0)
(12/38) Installing binutils-libs (2.28-r3)
(13/38) Installing binutils (2.28-r3)
(14/38) Installing gmp (6.1.2-r1)
(15/38) Installing isl (0.18-r0)
(16/38) Installing libgomp (6.4.0-r5)
(17/38) Installing libatomic (6.4.0-r5)
(18/38) Installing mpfr3 (3.1.5-r1)
(19/38) Installing mpc1 (1.0.3-r1)
(20/38) Installing gcc (6.4.0-r5)
(21/38) Installing musl-dev (1.1.18-r3)
(22/38) Installing libc-dev (0.7.1-r0)
(23/38) Installing g++ (6.4.0-r5)
(24/38) Installing libcurl (7.58.0-r0)
(25/38) Installing expat (2.2.5-r0)
(26/38) Installing pcre2 (10.30-r0)
(27/38) Installing git (2.15.0-r1)
(28/38) Installing libgmpxx (6.1.2-r1)
(29/38) Installing gmp-dev (6.1.2-r1)
(30/38) Installing libffi (3.2.1-r4)
(31/38) Installing llvm5-libs (5.0.0-r0)
(32/38) Installing llvm5 (5.0.0-r0)
(33/38) Installing make (4.2.1-r0)
(34/38) Installing libcrypto1.0 (1.0.2n-r0)
(35/38) Installing libssl1.0 (1.0.2n-r0)
(36/38) Installing openssl (1.0.2n-r0)
(37/38) Installing zlib-dev (1.2.11-r1)
(38/38) Installing openssl-dev (1.0.2n-r0)
Executing busybox-1.27.2-r7.trigger
Executing ca-certificates-20171114-r0.trigger
OK: 429 MiB in 50 packages
Cloning into '/bn'...
make -C mcl UPDATE_ASM=1 lib/libmcl.a CFLAGS_USER=-std=c++11 MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/mcl'
g++ -o src/gen src/gen.cpp -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1 -O0
src/gen -f src/func.list > src/base64.ll
opt -O3 -o - src/base64.ll -march=x86-64 | llc -O3 -o src/asm/x86-64.s -march=x86-64 -relocation-model=pic -pre-RA-sched=list-ilp -max-sched-reorder=128
g++ -c src/asm/x86-64.s -o obj/x86-64.o -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1
src/gen -f src/func.list -s bmi2 > src/base64.bmi2.ll
opt -O3 -o - src/base64.bmi2.ll -march=x86-64 | llc -O3 -o src/asm/x86-64.bmi2.s -march=x86-64 -relocation-model=pic -pre-RA-sched=list-ilp -max-sched-reorder=128 -mattr=bmi2
g++ -c src/asm/x86-64.bmi2.s -o obj/x86-64.bmi2.o -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1
g++ -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -std=c++11 -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -DMCL_MAX_BIT_SIZE=384 -DMCL_USE_LLVM=1 -c src/fp.cpp -o obj/fp.o -MMD -MP -MF obj/fp.d
ar r lib/libmcl.a obj/fp.o obj/x86-64.o obj/x86-64.bmi2.o
ar: creating lib/libmcl.a
make[1]: Leaving directory '/bn/mcl'
make -C bls MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/bls'
g++ -o libbls384.so src/bls_c.cpp -shared -g3 -Wall -Wextra -Wformat=2 -Wcast-qual -Wcast-align -Wwrite-strings -Wfloat-equal -Wpointer-arith -m64 -I include -I test -I ../xbyak -I ../cybozulib/include -fomit-frame-pointer -DNDEBUG -Ofast -march=native -fPIC -std=c++11 -I../mcl/include -I./include -DMCL_MAX_BIT_SIZE=384 -D"MCLBN_FP_UNIT_SIZE=6" ../mcl/lib/libmcl.a -lgmpxx -lgmp -lcrypto
make[1]: Leaving directory '/bn/bls'
mkdir -p /usr/local/lib
cp -a mcl/lib/libmcl.a /usr/local/lib
cp -a bls/libbls384.so /usr/local/lib
mkdir -p /usr/local/include/bls
cp -a bls/include/bls/bls.h /usr/local/include/bls
mkdir -p /usr/local/include/mcl
cp -a mcl/include/mcl/bn.h /usr/local/include/mcl
make -C mcl UPDATE_ASM=1 lib/libmcl.a CFLAGS_USER=-std=c++11 MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/mcl'
make[1]: 'lib/libmcl.a' is up to date.
make[1]: Leaving directory '/bn/mcl'
make -C bls MCL_MAX_BIT_SIZE=384
make[1]: Entering directory '/bn/bls'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/bn/bls'
WARNING: Ignoring APKINDEX.70c88391.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.5022a8a2.tar.gz: No such file or directory
(1/11) Purging clang (5.0.0-r0)
(2/11) Purging git (2.15.0-r1)
(3/11) Purging llvm5 (5.0.0-r0)
(4/11) Purging make (4.2.1-r0)
(5/11) Purging clang-libs (5.0.0-r0)
(6/11) Purging libxml2 (2.9.7-r0)
(7/11) Purging libcurl (7.58.0-r0)
(8/11) Purging expat (2.2.5-r0)
(9/11) Purging pcre2 (10.30-r0)
(10/11) Purging llvm5-libs (5.0.0-r0)
(11/11) Purging libffi (3.2.1-r4)
Executing busybox-1.27.2-r7.trigger
OK: 191 MiB in 39 packages
Removing intermediate container 0740f1d5b1d7
---> ecf6476859ff
There was a problem hiding this comment.
I'd like to have some spend a few minutes showing me how we use CircleCi. I bet that with very few modifications we can get this smaller, faster image working. Please see details below.
There was a problem hiding this comment.
Hmm... I don't see the detailed comments below, but if you go to #36 and scroll down and they should be there.
There was a problem hiding this comment.
Agreed that it'd be easy to adjust the build- I just don't want it broken in the meantime 🙂
It auto-runs on each PR- you can see that the client build is broken below.
There was a problem hiding this comment.
Here's the client build output. You can log in with GitHub and look at the config in .circle- https://circleci.com/gh/keep-network/keep-core/561
There was a problem hiding this comment.
It just occurred to me why the golang:1.9.4-alpine3.7 image didn't just work. It assumes that we are including the vendor directory in the keep-core repo.
It assumes that the developer that created the last Dockerfile successfully ran the build-keep-client-docker-img.sh and run-keep-client.sh scripts.
Adding the vendor directory to our git repo is recommended by the godep authors. The build-keep-client-docker-img.sh script works on the assumption that the vendor directory exists. Otherwise, the build server would need to run dep ensure, which is not preferable. For more details on why the vendor directory should be included, see:
https://github.com/tools/godep/blob/master/Readme.md
Here's what the output of running ./build-keep-client-docker-img.sh --force && ./run-keep-client.sh should look like:
docker-build-process ~/dev/go/keep-core-docker/src/github.com/keep-network/keep-core $ ./build-keep-client-docker-img.sh --force
WARNING: You are not on the master branch! Are you sure you want to continue? (CTRL+C to abort)
Your branch (local file system) is NOT up-to-date with the master branch.
Sending build context to Docker daemon 7.079MB
Step 1/9 : FROM golang:1.9.4-alpine3.7
---> fb6e10bf973b
Step 2/9 : ENV GOPATH=/go GOBIN=/go/bin APP_REPO_DIR=/go/src/keep-network/keep-client APP_NAME=keep-client
---> Using cache
---> a6b7785655e5
Step 3/9 : RUN apk add --update --no-cache bash clang g++ git gmp gmp-dev libgmpxx libstdc++ llvm make openssl openssl-dev && git clone https://github.com/dfinity/bn /bn && cd /bn && make install && make && rm -rf /bn && mkdir -p /go/src && rm -rf /var/cache/apk && mkdir /var/cache/apk && rm -rf /usr/share/man && apk del git make clang llvm && mkdir -p $APP_REPO_DIR
---> Using cache
---> 0d7ddea99545
Step 4/9 : ENV BN_VERSION=d1a44d2f242692601b3e150b59044ab82f265b65
---> Using cache
---> b1f40999c2c2
Step 5/9 : COPY ./go $APP_REPO_DIR
---> Using cache
---> 00ffc3b36cba
Step 6/9 : WORKDIR $APP_REPO_DIR
---> Using cache
---> 1bf30d688817
Step 7/9 : RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o $APP_NAME . && mv $APP_NAME /usr/local/bin && rm -rf $APP_REPO_DIR
---> Using cache
---> 591043609c0e
Step 8/9 : ENTRYPOINT ["keep-client"]
---> Using cache
---> 1b625ec14c38
Step 9/9 : CMD []
---> Using cache
---> f104e34f549b
Successfully built f104e34f549b
Successfully tagged keep-client:latest
docker-build-process ~/dev/go/keep-core-docker/src/github.com/keep-network/keep-core $ ./run-keep-client.sh
c628aa04a8bbefc8c5dfe13c8c8cd96e8b996c9c3fefa4f9baa452ee5cca5eb1
l3x
left a comment
There was a problem hiding this comment.
Not sure why that last comment would trigger the "Review changes" popup.
| @@ -0,0 +1,31 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
Hmm... I don't see the detailed comments below, but if you go to #36 and scroll down and they should be there.
Isn't this counter to the run times you posted? Looks like the subsequent build times are identical (which makes sense, since we're caching the faster work), unless I missed something?
What do we gain from this? How long does Error in the build: The continuous build doesn't run your script, it just runs the docker build, so I think we're missing all the Before we dive too much further down this rabbit hole, I'm wondering if it's worth the time investment. The initial build of the image is something we're all probably going to do once locally. Circle CI caches as well, so it will also rarely build the image from scratch. In the latest version of the Dockerfile, in fact, it won't even rerun In short, it feels like we might be investing time into optimizing something that is “Good Enough™”, and I'm concerned that we have much bigger fish to fry. Willing to be talked out of it though :) Thoughts? EDIT to note: The main reason I understood docker performance originally came up was Philip was having some serious performance issues (>1 minute incremental builds), but he ultimately traced these to a docker-VM issue, which is why I'm willing to punt spending much more time down this path for now. |
|
IMO a scaled-back version of this is worthwhile- Alpine is a big improvement over Ubuntu as a base image. I just don't want the build or dynamic libs broken :) |
|
Yeah, not much of a difference in "subsequent build times". But... what we gain from doing it outside the image is we can reduce the size of the image with 500+MB adds up. Libraries are configured properly for Looks like there is some configuration work for CircleCi to get the environment setup to run And I agree this is not a priority now. Thanks for sharing about Philips experience, it was hearing that, seeing this fresh PR and the fact that Docker was on my mind that took me down this rabbit hole. |
Multistage builds get us that benefit without any additional scripts or other issues weird build requirements.
How are you testing that? Doesn't look like there's code using
Let's definitely fix tests in our PRs as a bare minimum to consider a merge.
Multistage builds again. Example -> https://github.com/keep-network/slack-guardian/blob/d43938d432f800dea6653a5856e14daa2e5f7fee/Dockerfile |
| WORKDIR / | ||
| RUN apt-get update | ||
| RUN apt-get install -y llvm g++ libgmp-dev libssl-dev git-core build-essential | ||
| ENV BN_VERSION=d1a44d2f242692601b3e150b59044ab82f265b65 |
There was a problem hiding this comment.
Ah, this also doesn't use the pinned version of the C++ lib
* Smaller image (1/2 the size) * Faster initial build time (1/2 the time) * Faster subsequent build times
We'll revisit this once we've all discussed our CI setup in detail
fa426fb to
c7f378f
Compare
Thanks @Shadowfiend and @l3x!
Integrate tBTCv2 rewards generation script
threshold-network#36) Document the re-landed Tier 0 + Tier 1 work (lint rule + race-detector CI job + bounds-checked tx accessors, native fuzz targets) in Keep a Changelog format.
…in epic Combine the per-PR Keep a Changelog entries (threshold-network#36, threshold-network#37, threshold-network#34, threshold-network#38, threshold-network#39, threshold-network#40, #8, #2, #14) into shared Added/Changed/Fixed/Security sections under [Unreleased].
threshold-network#36) Document the re-landed Tier 0 + Tier 1 work (lint rule + race-detector CI job + bounds-checked tx accessors, native fuzz targets) in Keep a Changelog format.
…in epic Combine the per-PR Keep a Changelog entries (threshold-network#36, threshold-network#37, threshold-network#34, threshold-network#38, threshold-network#39, threshold-network#40, #8, #2, #14) into shared Added/Changed/Fixed/Security sections under [Unreleased].
Summary
Benefits of using golang alpine image
Unless there's a good reason not to, we should use golang 1.9.4
Process
To build
To build a new keep-client image, the developer or build engine runs
build-keep-client-docker-img.shscript in the/go/src/github.com/keep-network/keep-coredirectory.Note that the developer or build engine is required to be in a branch that is current with master.
This is because
dep ensureis run locally (developer workstation or build server environment).This creates the vendor directory which is copied into the image.
Docker installs packages required to build the keep-client (Go application).
Subsequently, Docker deletes build artifacts from the image.
Commands in the new Dockerfile have been optimized both for performance and for creating fewer layers in the Docker image's union file system.
Other Dockerfile best practices include:
To test
From same directory, run:
run-keep-client.shOutput should look like this:
Comparison Statistics
golang:1.9.2 stats:
golang:1.9.4-alpine3.7 stats:
Dockerfiles
golang:1.9.2
golang:1.9.4-alpine3.7
More details
Current FROM golang:1.9.2
$ time docker build -t keep-client -f Dockerfile .Approx. download time for base image: Varied between 1:26 and 2:21
Build time for 1:26 (best time) download run:
Make small change and re-run: docker build -t keep-client -f Dockerfile .
FROM golang:1.9.4-alpine3.7
$ time docker build -t keep-client -f Dockerfile .Approx. download time for base image: 0:20
Make small change and re-run: docker build -t keep-client -f Dockerfile .
Results from running the images are the same