Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slim container builds #1676

Merged
merged 13 commits into from
Oct 22, 2023
73 changes: 51 additions & 22 deletions files/docker/node/dockerfile_bin
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,65 @@ 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/

# ENTRY SCRIPT
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/banner.txt /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/guild-topology.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/block_watcher.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/healthcheck.sh /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 @@ -59,20 +94,14 @@ RUN curl -sL -H "Accept: application/vnd.github.everest-preview+json" -H "Conte


# ENTRY SCRIPT
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/banner.txt /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/guild-topology.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/block_watcher.sh /home/guild/.scripts/
ADD https://raw.githubusercontent.com/${G_ACCOUNT}/guild-operators/master/files/docker/node/addons/healthcheck.sh /home/guild/.scripts/
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"]