Skip to content

Commit

Permalink
Merge branch 'alpha' into koiosV1
Browse files Browse the repository at this point in the history
  • Loading branch information
rdlrt authored Oct 29, 2023
2 parents 53396ef + a1c37b6 commit 4ec2f4a
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 39 deletions.
25 changes: 12 additions & 13 deletions .github/workflows/premerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,21 @@ jobs:
BRANCH: ${{ github.event.inputs.branch || '' }}
if: github.event.pull_request.draft == false
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 30720
swap-size-mb: 1024
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: ' true'
remove-codeql: 'true'
- name: Provide additional free space
run: |
# Workaround to provide additional free space for builds.
# Workaround to provide additional free space for builds
# https://github.com/actions/virtual-environments/issues/2840
sudo apt-get update -y
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y 'php.*'
sudo apt-get remove -y azure-cli google-chrome-stable firefox powershell mono-devel
sudo apt-get autoremove -y
sudo apt-get clean
sudo rm -rf "/usr/share/dotnet"
sudo rm -rf "/usr/local/lib/android"
sudo rm -rf "/opt/ghc"
sudo rm -rf "/opt/hostedtoolcache/CodeQL"
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /usr/local/share/boost "$AGENT_TOOLSDIRECTORY"
df -h
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
Expand Down
23 changes: 23 additions & 0 deletions docs/docker/tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,26 @@ cardanocommunity/cardano-node:latest # Mandatory: image to run
#### Un-Official Docker managment cli tool
- [Lazydocker](https://github.com/jesseduffield/lazydocker)
### Docker backups and restores
The docker container has an optional backup and restore functionality that can be used to backup the `/opt/cardano/cnode/db` directory. To have the
backup persist longer than the countainer, the backup directory should be mounted as a volume.
[!NOTE]
The backup and restore functionality is disabled by default.
[!WARNING]
Make sure adequate space exists on the host as the backup will double the space consumed by the database.
#### Creating a Backup
When the container is started with the **ENABLE_BACKUP** environment variable set to **Y** the container will automatically create a
backup in the `/opt/cardano/cnode/backup/$NETWORK-db` directory. The backup will be created when the container is started and if the
backup directory is smaller than the db directory.
#### Restoring from a Backup
When the container is started with the **ENABLE_RESTORE** environment variable set to **Y** the container will automatically restore
the latest backup from the `/opt/cardano/cnode/backup/$NETWORK-db` directory. The database will be restored when the container is started
and if the backup directory is larger than the db directory.
22 changes: 14 additions & 8 deletions files/docker/node/addons/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ echo "NETWORK: $NETWORK $POOL_NAME $TOPOLOGY";
echo "NODE: $HOSTNAME - Port:$CNODE_PORT - $POOL_NAME";
cardano-node --version;

dbsize=$(du -s ${CNODE_HOME}/db | awk '{print $1}')
bksizedb=$(du -s $CNODE_HOME/priv/$NETWORK-db 2>/dev/null | awk '{print $1}')
if [[ "${ENABLE_BACKUP}" == "Y" ]] || [[ "${ENABLE_RESTORE}" == "Y" ]]; then
[[ ! -d "${CNODE_HOME}"/backup/$NETWORK-db ]] && mkdir -p $CNODE_HOME/backup/$NETWORK-db
dbsize=$(du -s $CNODE_HOME/db | awk '{print $1}')
bksizedb=$(du -s $CNODE_HOME/backup/$NETWORK-db 2>/dev/null | awk '{print $1}')
if [[ "${ENABLE_RESTORE}" == "Y" ]] && [[ "$dbsize" -lt "$bksizedb" ]]; then
echo "Backup Started"
cp -rf "${CNODE_HOME}"/backup/"${NETWORK}"-db/* "${CNODE_HOME}"/db 2>/dev/null
echo "Backup Finished"
fi

if [[ "$dbsize" -lt "$bksizedb" ]]; then
cp -rf $CNODE_HOME/priv/$NETWORK-db/* ${CNODE_HOME}/db 2>/dev/null
fi

if [[ "$dbsize" -gt "$bksizedb" ]]; then
cp -rf $CNODE_HOME/db/* $CNODE_HOME/priv/$NETWORK-db/ 2>/dev/null
if [[ "${ENABLE_BACKUP}" == "Y" ]] && [[ "$dbsize" -gt "$bksizedb" ]]; then
echo "Restore Started"
cp -rf "${CNODE_HOME}"/db/* "${CNODE_HOME}"/backup/"${NETWORK}"-db/ 2>/dev/null
echo "Restore Finished"
fi
fi

# Customisation
Expand Down
64 changes: 46 additions & 18 deletions files/docker/node/dockerfile_bin
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,60 @@ ENV \
PATH=/opt/cardano/cnode/scripts:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/home/guild/.local/bin \
GIT_SSL_CAINFO=/etc/ssl/certs/ca-certificates.crt

RUN apt-get update && apt-get install --no-install-recommends -y locales apt-utils sudo \
&& apt install -y curl wget gnupg git udev \
&& apt-get -y purge \
&& apt-get -y clean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/* \
&& sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \
&& locale-gen \
&& echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc \
&& echo "export LANG=en_US.UTF-8" >> ~/.bashrc \
&& echo "export LANGUAGE=en_US.UTF-8" >> ~/.bashrc \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

RUN adduser --disabled-password --gecos '' guild \
&& adduser guild sudo \
&& mkdir -pv /home/guild/.local/ /home/guild/.scripts/


RUN set -x && apt update \
&& apt-get update \
&& mkdir -p /root/.local/bin \
&& apt install -y curl wget gnupg apt-utils git udev \
&& wget https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/guild-deploy.sh \
&& export SUDO='N' \
&& export UPDATE_CHECK='N' \
&& export SKIP_DBSYNC_DOWNLOAD='Y' \
&& chmod +x ./guild-deploy.sh && ./guild-deploy.sh -b master -s pdcowx \
&& chmod +x ./guild-deploy.sh && ./guild-deploy.sh -b master -s p \
&& ls /opt/ \
&& mkdir -p $CNODE_HOME/priv/files \
&& apt-get update && apt-get install --no-install-recommends -y locales apt-utils \
&& sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen \
&& locale-gen \
&& echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc \
&& echo "export LANG=en_US.UTF-8" >> ~/.bashrc \
&& echo "export LANGUAGE=en_US.UTF-8" >> ~/.bashr \
&& apt-get install -y procps libcap2 libselinux1 libc6 libsodium-dev ncurses-bin iproute2 curl wget apt-utils xz-utils netbase sudo coreutils dnsutils net-tools procps tcptraceroute bc usbip sqlite3 python3 tmux jq ncurses-base libtool autoconf git gnupg tcptraceroute util-linux less openssl bsdmainutils dialog vim \
&& apt-get -y remove libpq-dev build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ && apt-get -y purge && apt-get -y clean && apt-get -y autoremove && rm -rf /var/lib/apt/lists/* \
&& apt-get -y remove libpq-dev build-essential pkg-config libffi-dev libgmp-dev libssl-dev libtinfo-dev libsystemd-dev zlib1g-dev make g++ \
&& apt-get -y purge \
&& apt-get -y clean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*


RUN set -x && export SUDO='N' \
&& export UPDATE_CHECK='N' \
&& export SKIP_DBSYNC_DOWNLOAD='Y' \
&& ./guild-deploy.sh -b master -s dcowx \
&& cd /usr/bin \
&& wget http://www.vdberg.org/~richard/tcpping \
&& chmod 755 tcpping \
&& adduser --disabled-password --gecos '' guild \
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
&& adduser guild sudo
&& chown -R guild:guild $CNODE_HOME/* \
&& mv /root/.local/bin /home/guild/.local/ \
&& chown -R guild:guild /home/guild/.* \
&& chmod a+x /home/guild/.scripts/*.sh /opt/cardano/cnode/scripts/*.sh

# Add final tools in a separate layer to shrink the largest layer
RUN apt-get update \
&& apt-get install -y procps libcap2 libselinux1 libc6 libsodium-dev ncurses-bin iproute2 xz-utils netbase coreutils dnsutils net-tools procps tcptraceroute bc usbip sqlite3 python3 tmux jq ncurses-base libtool autoconf tcptraceroute util-linux less openssl bsdmainutils dialog vim \
&& apt-get -y purge \
&& apt-get -y clean \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*

USER guild
WORKDIR /home/guild
Expand All @@ -66,13 +96,11 @@ ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/scripts/cnode-helper-scripts/guild-deploy.sh /opt/cardano/cnode/scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/entrypoint.sh ./

RUN sudo chown -R guild:guild $CNODE_HOME/* \
&& mkdir /home/guild/.local/ \
&& sudo mv /root/.local/bin /home/guild/.local/ \
&& sudo chown -R guild:guild /home/guild/.* \
&& sudo chmod a+x /home/guild/.scripts/*.sh /opt/cardano/cnode/scripts/*.sh /home/guild/entrypoint.sh
RUN sudo chmod a+rx /home/guild/.scripts/*.sh /opt/cardano/cnode/scripts/*.sh /home/guild/entrypoint.sh \
&& sudo chown -R guild:guild /home/guild/.* $CNODE_HOME/*

HEALTHCHECK --start-period=5m --interval=5m --timeout=100s CMD /home/guild/.scripts/healthcheck.sh

ENTRYPOINT ["./entrypoint.sh"]


0 comments on commit 4ec2f4a

Please sign in to comment.