Skip to content

Commit

Permalink
dockerfile prepared for upgrade, docs cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlp4 committed May 30, 2022
1 parent 7be2d53 commit 6bb68e2
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 127 deletions.
185 changes: 68 additions & 117 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,158 +1,109 @@
###########################################################################################
# Build cyber
###########################################################################################
FROM ubuntu:20.04 as build_stage_cuda
FROM ubuntu:20.04

ENV GO_VERSION '1.17.8'
ENV GO_ARCH 'linux-amd64'
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"
ENV PATH /usr/local/go/bin:/root/.cargo/bin:/root/cargo/env:/root/.cyber/scripts:$PATH
#ENV CUDA_VER '11.6.1-1'
ENV CUDA_VER '11.4.4-1'
ENV PATH="/usr/local/go/bin:/usr/local/cuda/bin:$PATH"


# Install required dev tools to compile cyber
# 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:/usr/local/cuda/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 \
# gnupg \
# software-properties-common \
nvidia-cuda-toolkit \
&& go version

# Install requested CUDA version
###########################################################################################
#RUN 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/7fa2af80.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

# Create appropriate folders layout
###########################################################################################
RUN mkdir -p /cyber/cosmovisor/genesis/bin \
&& mkdir -p /cyber/cosmovisor/upgrades/upgrade-1/bin
# Compile cosmovisor
###########################################################################################
RUN git clone --depth 1 https://github.com/cosmos/cosmos-sdk.git $BUILD_DIR/ \
&& cd $BUILD_DIR/cosmovisor/ \
&& make cosmovisor \
&& cp cosmovisor /usr/bin/cosmovisor \
&& chmod +x /usr/bin/cosmovisor \
&& rm -fR $BUILD_DIR/* && rm -fR $BUILD_DIR/.*[a-z]

###########################################################################################
# Build wasmvm
###########################################################################################
#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/

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
###########################################################################################

WORKDIR /sources
RUN git checkout v0.2.0 \
&& make build CUDA_ENABLED=true \
&& chmod +x ./build/cyber \
&& cp ./build/cyber /cyber/cosmovisor/genesis/bin/ \
&& cp ./build/cyber /usr/local/bin \
&& rm -rf ./build \
&& git reset --hard


&& 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

WORKDIR /sources
RUN git checkout upgrade-1 \
&& make build CUDA_ENABLED=true \
&& chmod +x ./build/cyber \
&& cp ./build/cyber /cyber/cosmovisor/upgrades/upgrade-1/bin/ \
&& 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 DAEMON_NAME cyber
ENV DAEMON_ALLOW_DOWNLOAD_BINARIES=false
ENV DAEMON_LOG_BUFFER_SIZE=812
ENV UNSAFE_SKIP_BACKUP=true

# Install useful dev tools
# Install cosmovisor
###########################################################################################
#RUN apt-get update && apt-get install -y --no-install-recommends wget curl ca-certificates
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 cosmovisor.tgz && rm -fR $BUILD_DIR/* && rm -fR $BUILD_DIR/.*[a-z]

# Download genesis file and links file from IPFS
# Copy startup scripts and genesis
###########################################################################################
RUN wget -O /genesis.json https://gateway.ipfs.cybernode.ai/ipfs/QmQaux3zRF5ucdmtGYEVeNZTBfryfX4e49mj57SusMCo1p

WORKDIR /

# Copy compiled kernel and binaries for current bin version
###########################################################################################
#COPY --from=build_stage_cuda /cyber /cyber

#COPY /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 go version
RUN cyber version
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 20660
EXPOSE 26656 26657 1317 9090 26660
ENTRYPOINT ["/entrypoint.sh"]
CMD ["./start_script.sh"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</div>

<div align="center">
<h3>Join us, Hero - <a href="https://github.com/cybercongress/go-cyber/blob/bostrom-dev/docs/run_validator.md">Setup validator guide</a></h3>
<h3>Join us, Hero - <a href="https://github.com/cybercongress/go-cyber/blob/main/docs/run_validator.md">Setup validator guide</a></h3>
</div>

<div align="center">
Expand Down Expand Up @@ -51,7 +51,7 @@ _____________

## Blockchain

[![chain](https://img.shields.io/badge/Chain-bostrom-success.svg?style=flat-square)](https://github.com/cybercongress/cyberd/blob/master/docs/run_validator.md)
[![chain](https://img.shields.io/badge/Chain-bostrom-success.svg?style=flat-square)](https://github.com/cybercongress/go-cyber/blob/main/docs/run_validator.md)
[![block](https://img.shields.io/badge/dynamic/json?color=blue&label=Block%20Height&query=%24.result.sync_info.latest_block_height&url=https://rpc.bostrom.cybernode.ai/status&style=flat-square)]()
[![cyberlinks](https://img.shields.io/badge/dynamic/json?color=blue&label=Cyberlinks&query=%24.result.cyberlinks&url=https://lcd.bostrom.cybernode.ai/graph/graph_stats&style=flat-square)]()
[![particles](https://img.shields.io/badge/dynamic/json?color=blue&label=Particles&query=%24.result.particles&url=https://lcd.bostrom.cybernode.ai/graph/graph_stats&style=flat-square)]()
Expand Down
6 changes: 0 additions & 6 deletions docs/run_validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,6 @@ sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```

6. Reboot the system for the changes to take effect.

```bash
sudo reboot
```

### Installing Nvidia drivers

1. To proceed, first add the `ppa:graphics-drivers/ppa` repository:
Expand Down
4 changes: 2 additions & 2 deletions docs/ultimate-commands-guide.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ultimate cyberd CLI guide. Chain: bostrom
# Ultimate cyber CLI guide. Chain: bostrom

## Install cyberd client
## Install cyber client

It is possible to interact with cyber even if you don't have your own node. All you need to do is install `cyber` client on your machine using the script below, paste it in the console (currently Linux supported):

Expand Down

0 comments on commit 6bb68e2

Please sign in to comment.