-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #625 from cybercongress/cyberfrey
- Loading branch information
Showing
29 changed files
with
928 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,109 @@ | ||
########################################################################################### | ||
# Build cyber | ||
########################################################################################### | ||
FROM ubuntu:20.04 as build_stage_cuda | ||
FROM ubuntu:20.04 | ||
|
||
ENV GO_VERSION '1.17.2' | ||
ENV GO_VERSION '1.17.8' | ||
ENV GO_ARCH 'linux-amd64' | ||
ENV GO_BIN_SHA 'f242a9db6a0ad1846de7b6d94d507915d14062660616a61ef7c808a76e4f1676' | ||
ENV GO_BIN_SHA '980e65a863377e69fd9b67df9d8395fd8e93858e7a24c9f55803421e453f4f99' | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ENV DAEMON_HOME /root/.cyber | ||
ENV DAEMON_RESTART_AFTER_UPGRADE=true | ||
ENV DAEMON_ALLOW_DOWNLOAD_BINARIES=false | ||
ENV DAEMON_LOG_BUFFER_SIZE=1048 | ||
ENV UNSAFE_SKIP_BACKUP=true | ||
ENV DAEMON_NAME cyber | ||
ENV BUILD_DIR /build | ||
ENV COSMWASM_VER "1.0.0-beta" | ||
ENV PATH /usr/local/go/bin:/root/.cargo/bin:/root/cargo/env:/root/.cyber/scripts:$PATH | ||
ENV CUDA_VER '11.4.4-1' | ||
ENV PATH="/usr/local/go/bin:/usr/local/cuda/bin:$PATH" | ||
|
||
|
||
# Install required dev tools to compile cyberd | ||
# Install go and required deps | ||
########################################################################################### | ||
RUN apt-get update && apt-get install -y --no-install-recommends wget git ca-certificates | ||
RUN apt-get update && apt-get install -y --no-install-recommends wget ca-certificates \ | ||
&& wget -O go.tgz https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz \ | ||
&& echo "${GO_BIN_SHA} *go.tgz" | sha256sum -c - \ | ||
&& tar -C /usr/local -xzf go.tgz \ | ||
&& rm go.tgz \ | ||
&& go version | ||
|
||
# Install golang | ||
########################################################################################### | ||
RUN wget -O go.tgz https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz && \ | ||
echo "${GO_BIN_SHA} *go.tgz" | sha256sum -c - && \ | ||
tar -C /usr/local -xzf go.tgz &&\ | ||
rm go.tgz | ||
|
||
ENV PATH="/usr/local/go/bin:$PATH" | ||
COPY . /sources | ||
WORKDIR /sources | ||
|
||
# Install CUDA, build tools and compile cyber | ||
########################################################################################### | ||
RUN apt-get -y install --no-install-recommends \ | ||
make gcc g++ \ | ||
wget \ | ||
curl \ | ||
gnupg \ | ||
git \ | ||
nvidia-cuda-toolkit \ | ||
&& go version | ||
software-properties-common \ | ||
# nvidia-cuda-toolkit \ | ||
# Install cuda selected version instead nvidia-cuda-toolkit | ||
&& wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin \ | ||
&& mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 \ | ||
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub \ | ||
&& add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /" \ | ||
&& apt-get update \ | ||
&& apt-get install cuda=${CUDA_VER} -y --no-install-recommends \ | ||
&& mkdir -p /cyber/cosmovisor/genesis/bin \ | ||
&& mkdir -p /cyber/cosmovisor/upgrades/cyberfrey/bin \ | ||
# Compile cyber for genesis version | ||
########################################################################################### | ||
&& git checkout v0.2.0 \ | ||
&& cd /sources/x/rank/cuda \ | ||
&& make build \ | ||
&& cd /sources \ | ||
&& make build CUDA_ENABLED=true \ | ||
&& cp ./build/cyber /cyber/cosmovisor/genesis/bin/ \ | ||
&& cp ./build/cyber /usr/local/bin \ | ||
&& rm -rf ./build \ | ||
# Compile cyber for genesis version | ||
########################################################################################### | ||
&& git checkout v0.3.0 \ | ||
&& cd /sources/x/rank/cuda \ | ||
&& make build \ | ||
&& cd /sources \ | ||
&& make build CUDA_ENABLED=true \ | ||
&& cp ./build/cyber /cyber/cosmovisor/upgrades/cyberfrey/bin/ \ | ||
&& rm -rf ./build \ | ||
# Cleanup | ||
########################################################################################### | ||
&& apt-get purge -y git \ | ||
make \ | ||
cuda \ | ||
gcc g++ \ | ||
curl \ | ||
gnupg \ | ||
python3.8 \ | ||
&& go clean --cache -i \ | ||
&& apt-get remove --purge '^nvidia-.*' -y \ | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean | ||
|
||
# Create appropriate folders layout | ||
########################################################################################### | ||
RUN mkdir -p /cyber/cosmovisor/genesis/bin | ||
# Compile cosmovisor | ||
# Install cosmovisor | ||
########################################################################################### | ||
RUN git clone --depth 1 https://github.com/cosmos/cosmos-sdk.git $BUILD_DIR/ \ | ||
&& cd $BUILD_DIR/cosmovisor/ \ | ||
&& make cosmovisor \ | ||
RUN wget -O cosmovisor.tgz https://github.com/cosmos/cosmos-sdk/releases/download/cosmovisor%2Fv1.1.0/cosmovisor-v1.1.0-linux-amd64.tar.gz \ | ||
&& tar -xzf cosmovisor.tgz \ | ||
&& cp cosmovisor /usr/bin/cosmovisor \ | ||
&& chmod +x /usr/bin/cosmovisor \ | ||
&& rm -fR $BUILD_DIR/* && rm -fR $BUILD_DIR/.*[a-z] | ||
&& rm cosmovisor.tgz && rm -fR $BUILD_DIR/* && rm -fR $BUILD_DIR/.*[a-z] | ||
|
||
########################################################################################### | ||
# Build wasmvm | ||
# Copy startup scripts and genesis | ||
########################################################################################### | ||
WORKDIR / | ||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y \ | ||
&& wget --quiet https://github.com/CosmWasm/wasmvm/archive/v${COSMWASM_VER}.tar.gz -P /tmp \ | ||
&& tar xzf /tmp/v${COSMWASM_VER}.tar.gz -C $BUILD_DIR \ | ||
&& cd $BUILD_DIR/wasmvm-${COSMWASM_VER}/ && make build \ | ||
&& cp $BUILD_DIR/wasmvm-${COSMWASM_VER}/api/libwasmvm.so /usr/lib/ \ | ||
&& cp $BUILD_DIR/wasmvm-${COSMWASM_VER}/api/libwasmvm.dylib /usr/lib/ | ||
|
||
# Compile cuda kernel | ||
########################################################################################### | ||
COPY . /sources | ||
WORKDIR /sources/x/rank/cuda | ||
RUN make build | ||
RUN cp ./build/libcbdrank.so /usr/lib/ && cp cbdrank.h /usr/lib/ | ||
|
||
# Compile cyberd for genesis version | ||
########################################################################################### | ||
|
||
WORKDIR /sources | ||
RUN make build CUDA_ENABLED=true \ | ||
&& chmod +x ./build/cyber \ | ||
&& cp ./build/cyber /cyber/cosmovisor/genesis/bin/ \ | ||
&& cp ./build/cyber /cyber/ \ | ||
&& rm -rf ./build \ | ||
&& git reset --hard | ||
|
||
########################################################################################### | ||
# Create runtime cyber image | ||
########################################################################################### | ||
FROM ubuntu:20.04 | ||
|
||
ENV DAEMON_HOME /root/.cyber | ||
ENV DAEMON_RESTART_AFTER_UPGRADE=true | ||
ENV GAIA_HOME ${DAEMON_HOME} | ||
ENV DAEMON_NAME cyber | ||
|
||
# Install useful dev tools | ||
########################################################################################### | ||
RUN apt-get update && apt-get install -y --no-install-recommends wget curl ca-certificates | ||
|
||
# Download genesis file and links file from IPFS | ||
########################################################################################### | ||
RUN wget -O /genesis.json https://gateway.ipfs.cybernode.ai/ipfs/QmYubyVNfghD4xCrTFj26zBwrF9s5GJhi1TmxvrwmJCipr | ||
|
||
WORKDIR / | ||
|
||
# Copy compiled kernel and binaries for current bin version | ||
########################################################################################### | ||
COPY --from=build_stage_cuda /cyber /cyber | ||
|
||
COPY --from=build_stage_cuda /cyber/cyber /usr/bin | ||
|
||
COPY --from=build_stage_cuda /usr/bin/cosmovisor /usr/bin/cosmovisor | ||
|
||
COPY --from=build_stage_cuda /usr/lib/cbdrank.h /usr/lib/cbdrank.h | ||
COPY --from=build_stage_cuda /usr/lib/libcbdrank.so /usr/lib/libcbdrank.so | ||
|
||
COPY --from=build_stage_cuda /usr/lib/libwasmvm.so /usr/lib/libwasmvm.so | ||
COPY --from=build_stage_cuda /usr/lib/libwasmvm.dylib /usr/lib/libwasmvm.dylib | ||
|
||
# Copy startup scripts | ||
########################################################################################### | ||
|
||
COPY start_script.sh start_script.sh | ||
COPY entrypoint.sh /entrypoint.sh | ||
RUN chmod +x start_script.sh | ||
RUN chmod +x /entrypoint.sh | ||
RUN wget -O /genesis.json https://gateway.ipfs.cybernode.ai/ipfs/QmYubyVNfghD4xCrTFj26zBwrF9s5GJhi1TmxvrwmJCipr \ | ||
&& chmod +x start_script.sh \ | ||
&& chmod +x /entrypoint.sh \ | ||
&& cyber version | ||
|
||
|
||
# Start | ||
############################################################################### | ||
EXPOSE 26656 26657 1317 9090 | ||
EXPOSE 26656 26657 1317 9090 26660 | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
CMD ["./start_script.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.