forked from Consensys/constellation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-linux-static.dockerfile
51 lines (45 loc) · 2.17 KB
/
build-linux-static.dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Dockerfile for building static constellation binaries using musl
# To run: % docker build -f build-static.dockerfile .
# Use image with GHC 8 on Alpine Linux
FROM mitchty/alpine-ghc:latest
RUN apk update
RUN apk add alpine-sdk git ca-certificates gmp-dev zlib-dev libsodium-dev db-dev ncurses-dev ncurses-static
# Compile db statically from source since there's no -static package
WORKDIR /usr/local/src
RUN wget http://download.oracle.com/berkeley-db/db-5.3.28.tar.gz
RUN tar xfz db-5.3.28.tar.gz
WORKDIR /usr/local/src/db-5.3.28/build_unix
RUN ../dist/configure --prefix=/usr \
--enable-compat185 \
--enable-dbm \
--enable-static \
--enable-cxx && \
make
RUN make docdir=/usr/local/share/doc/db-5.3.28 install
# Install stack
ADD https://s3.amazonaws.com/static-stack/stack-1.1.2-x86_64 /usr/local/bin/stack
RUN chmod 755 /usr/local/bin/stack
# Compile constellation
ADD ./ /usr/local/src/constellation
WORKDIR /usr/local/src/constellation
RUN stack install --local-bin-path /usr/local/bin --test --ghc-options '-optl-static -fPIC'
# Optional: Compress with upx for a smaller file size
# ADD https://github.com/lalyos/docker-upx/releases/download/v3.91/upx /usr/local/bin/upx
# RUN chmod 755 /usr/local/bin/upx
# RUN upx --best --ultra-brute /usr/local/bin/constellation-node
# RUN upx --best --ultra-brute /usr/local/bin/constellation-enclave-keygen
# Binaries are available in the container:
# Get the image ID: % docker images
# Start a container: % docker run -t -i <imageid> /bin/bash
# Get the container ID: % docker ps
# % docker cp <containerid>:/usr/local/bin/constellation-node .
# % docker cp <containerid>:/usr/local/bin/constellation-enclave-keygen .
#
# Keep the image, restart it and check out constellation from Github to quickly
# recompile later on (without recompiling dependencies):
# % cd /usr/local/src && rm -rf constellation
# % git clone [email protected]:jpmorganchase/constellation.git && cd constellation
# (or use 'docker cp' to copy your local repository.)
#
# Just remember to run stack with these options:
# % stack install --local-bin-path /usr/local/bin --test --ghc-options '-optl-static -fPIC'