contract migration image build improvements

This commit is contained in:
Blair Vanderlugt 2021-03-13 18:50:36 +00:00
parent 3661e48fd1
commit 842cbadf00

View File

@ -1,14 +1,21 @@
#FROM ethereum/solc:0.6.12 FROM python:3.8.6-slim-buster as compile-image
FROM ethereum/solc:0.8.0
# The solc image messes up the alpine environment, so we have to go all over again RUN apt-get update
FROM alpine RUN apt-get install -y --no-install-recommends git gcc g++ libpq-dev gawk jq telnet wget openssl iputils-ping gnupg socat bash procps make python2 cargo
COPY --from=0 /usr/bin/solc /usr/bin/solc
RUN apk update && \ RUN apt-get install -y software-properties-common
apk add make git RUN add-apt-repository ppa:ethereum/ethereum
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1C52189C923F6CA9
WORKDIR /usr/src RUN apt-get update
RUN apt-get install solc
RUN pip install --upgrade pip
WORKDIR /root
RUN mkdir -vp /usr/local/etc/cic
COPY contract-migration/nvm.sh .
ENV CONFINI_DIR /usr/local/etc/cic/
RUN mkdir -vp $CONFINI_DIR
ARG cic_config_commit=35c69ba75f00c8147150acf325565d5391cf25bf ARG cic_config_commit=35c69ba75f00c8147150acf325565d5391cf25bf
ARG cic_config_url=https://gitlab.com/grassrootseconomics/cic-config.git/ ARG cic_config_url=https://gitlab.com/grassrootseconomics/cic-config.git/
@ -16,11 +23,8 @@ RUN echo Install confini schema files && \
git clone --depth 1 $cic_config_url cic-config && \ git clone --depth 1 $cic_config_url cic-config && \
cd cic-config && \ cd cic-config && \
git fetch --depth 1 origin $cic_config_commit && \ git fetch --depth 1 origin $cic_config_commit && \
git checkout $cic_config_commit && \ git checkout $cic_config_commit && \
mkdir -vp /usr/local/etc/cic && \ cp -v *.ini $CONFINI_DIR
cp -v *.ini /usr/local/etc/cic/
ENV CONFINI_DIR /usr/local/etc/cic
ARG cic_contracts_commit=698ef3a30fde8d7f2c498f1208fb0ff45d665501 ARG cic_contracts_commit=698ef3a30fde8d7f2c498f1208fb0ff45d665501
ARG cic_contracts_url=https://gitlab.com/grassrootseconomics/cic-contracts.git/ ARG cic_contracts_url=https://gitlab.com/grassrootseconomics/cic-contracts.git/
@ -31,30 +35,6 @@ RUN echo Install ABI collection for solidity interfaces used across all componen
git checkout $cic_contracts_commit && \ git checkout $cic_contracts_commit && \
make install make install
#COPY ./Makefile ./cic-contracts/Makefile
#COPY ./*.sol ./cic-contracts/
#RUN cd cic-contracts && \
# make -B && make install -B
FROM python:3.8.6-slim-buster
COPY --from=1 /usr/local/share/cic/ /usr/local/share/cic/
COPY --from=1 /usr/local/etc/ /usr/local/etc/
LABEL authors="Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746"
LABEL spdx-license-identifier="GPL-3.0-or-later"
LABEL description="Base layer for buiding development images for the cic component suite"
RUN apt-get update && \
apt-get install -y git gcc g++ libpq-dev && \
apt-get install -y vim gawk jq telnet openssl iputils-ping curl wget gnupg socat bash procps make python2 postgresql-client
RUN echo installing nodejs tooling
COPY contract-migration/nvm.sh /root/
# Install nvm with node and npm # Install nvm with node and npm
# https://stackoverflow.com/questions/25899912/how-to-install-nvm-in-docker # https://stackoverflow.com/questions/25899912/how-to-install-nvm-in-docker
ENV NVM_DIR /root/.nvm ENV NVM_DIR /root/.nvm
@ -65,59 +45,80 @@ RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh |
&& . $NVM_DIR/nvm.sh \ && . $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \ && nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \ && nvm alias default $NODE_VERSION \
&& nvm use $NODE_VERSION \ && nvm use $NODE_VERSION
# So many ridiculously stupid issues with node in docker that take oceans of absolutely wasted time to resolve # So many ridiculously stupid issues with node in docker that take oceans of absolutely wasted time to resolve
# owner of these files is "1001" by default - wtf # owner of these files is "1001" by default - wtf
&& chown -R root:root "$NVM_DIR/versions/node/v$NODE_VERSION" # && chown -R root:root "$NVM_DIR/versions/node/v$NODE_VERSION"
ENV NODE_PATH $NVM_DIR/versions/node//v$NODE_VERSION/lib/node_modules ENV NODE_PATH $NVM_DIR/versions/node//v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node//v$NODE_VERSION/bin:$PATH ENV PATH $NVM_DIR/versions/node//v$NODE_VERSION/bin:$PATH
# RUN pip install --user --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version
ARG pip_extra_index_url=https://pip.grassrootseconomics.net:8433 ARG pip_extra_index_url=https://pip.grassrootseconomics.net:8433
ARG cic_base_version=0.1.1a23
ARG cic_registry_version=0.5.3a24
RUN pip install --user --extra-index-url $pip_extra_index_url cic-registry==$cic_registry_version cic-base[full_graph]==$cic_base_version
# ARG cic_bancor_url=https://gitlab.com/grassrootseconomics/cic-bancor.git/
# ARG cic_bancor_contracts_url=https://github.com/bancorprotocol/contracts-solidity
# RUN echo Compile and install bancor protocol contracts && \
# git clone --depth 1 $cic_bancor_url cic-bancor && \
# cd cic-bancor
# RUN cd cic-bancor/python && \
# pip install --extra-index-url $pip_extra_index_url .
# This is a temporary solution for building the Bancor contracts using the bancor protocol repository truffle setup # This is a temporary solution for building the Bancor contracts using the bancor protocol repository truffle setup
# We should instead flatten the files ourselves and build them with solc in the first image layer in this file # We should instead flatten the files ourselves and build them with solc in the first image layer in this file
ARG cic_bancor_commit=a04c7ae6882ea515938d852cc861d59a35070094 # ARG cic_bancor_commit=a04c7ae6882ea515938d852cc861d59a35070094
ARG cic_bancor_url=https://gitlab.com/grassrootseconomics/cic-bancor.git/ # ARG cic_bancor_url=https://gitlab.com/grassrootseconomics/cic-bancor.git/
ARG cic_bancor_contracts_url=https://github.com/bancorprotocol/contracts-solidity # ARG cic_bancor_contracts_url=https://github.com/bancorprotocol/contracts-solidity
RUN echo Compile and install bancor protocol contracts && \ # RUN echo Compile and install bancor protocol contracts && \
git clone --depth 1 $cic_bancor_url cic-bancor && \ # git clone --depth 1 $cic_bancor_url cic-bancor && \
cd cic-bancor && \ # cd cic-bancor && \
git fetch --depth 1 origin $cic_bancor_commit && \ # git fetch --depth 1 origin $cic_bancor_commit && \
git checkout $cic_bancor_commit && \ # git checkout $cic_bancor_commit && \
# Apparently the git version here doesn't have set-url as a command. *sigh* # # Apparently the git version here doesn't have set-url as a command. *sigh*
#if [ ! -z $cic_bancor_contracts_url ]; then # #if [ ! -z $cic_bancor_contracts_url ]; then
# git submodule set-url bancor $cic_bancor_contracts_url # # git submodule set-url bancor $cic_bancor_contracts_url
#fi # #fi
git submodule init && \ # git submodule init && \
git submodule update # git submodule update
RUN cd root && \ # RUN cd root && \
. $NVM_DIR/nvm.sh &&\ # . $NVM_DIR/nvm.sh &&\
nvm install $BANCOR_NODE_VERSION && \ # nvm install $BANCOR_NODE_VERSION && \
nvm use $BANCOR_NODE_VERSION && \ # nvm use $BANCOR_NODE_VERSION && \
cd - && \ # cd - && \
cd cic-bancor/bancor && \ # cd cic-bancor/bancor && \
npm install --python=/usr/bin/python2 && \ # npm install --python=/usr/bin/python2 && \
node_modules/truffle/build/cli.bundled.js compile && \ # node_modules/truffle/build/cli.bundled.js compile && \
mkdir -vp /usr/local/share/cic/bancor/solidity/build && \ # mkdir -vp /usr/local/share/cic/bancor/solidity/build && \
cp -vR solidity/build/contracts /usr/local/share/cic/bancor/solidity/build/ # cp -vR solidity/build/contracts /usr/local/share/cic/bancor/solidity/build/
RUN cd cic-bancor/python && \ # RUN cd cic-bancor/python && \
pip install --extra-index-url $pip_extra_index_url . # pip install --extra-index-url $pip_extra_index_url .
FROM python:3.8.6-slim-buster as runtime-image
RUN apt-get install -y cargo COPY --from=compile-image /usr/local/bin/ /usr/local/bin/
ARG cic_base_version=0.1.1a23 COPY --from=compile-image /usr/local/etc/cic/ /usr/local/etc/cic/
RUN pip install --extra-index-url $pip_extra_index_url cic-base[full_graph]==$cic_base_version
ARG cic_registry_version=0.5.3a24 RUN mkdir -p /tmp/cic/config
RUN pip install --extra-index-url $pip_extra_index_url cic-registry==$cic_registry_version RUN chmod a+rw /tmp/cic/config
WORKDIR /root ENV HOME /home/grassroots
RUN useradd --create-home grassroots
WORKDIR $HOME
# COPY python dependencies to user dir
COPY --from=compile-image /root/.local .local
RUN chown -R grassroots:grassroots $HOME/.local/
ENV PATH=$HOME/.local/bin:$PATH
USER grassroots
COPY contract-migration/testdata/pgp testdata/pgp COPY contract-migration/testdata/pgp testdata/pgp
COPY contract-migration/wait-for-it.sh . COPY contract-migration/wait-for-it.sh .
RUN chmod +x ./wait-for-it.sh # RUN chmod +x ./wait-for-it.sh
# COPY contract-migration/.env_config_template .env_config_template # COPY contract-migration/.env_config_template .env_config_template
# COPY contract-migration/.env_dockercompose_template .env_dockercompose_template # COPY contract-migration/.env_dockercompose_template .env_dockercompose_template
@ -129,4 +130,4 @@ COPY contract-migration/sarafu_declaration.json sarafu_declaration.json
COPY contract-migration/keystore keystore COPY contract-migration/keystore keystore
COPY contract-migration/envlist . COPY contract-migration/envlist .
# ENTRYPOINT [ "/bin/bash" ] ENTRYPOINT [ ]