node-distro/Dockerfile
2022-07-15 23:09:53 +03:00

145 lines
5.1 KiB
Docker

ARG COMMIT
ARG SERVICES_VERSION
ARG RUN_NUMBER
ARG TAG
ARG BUILD_DATE
ARG IPFS_VERSION=0.13.1
ARG CERAMIC_VERSION=2.3.x
ARG GLAZED_VERSION=0.2.x
ARG GETH_VERSION=1.10
ARG BITCOIN_CLI_VERSION=23.0
# prepare stage images
# ----------------------------------------------------------------------------
FROM ethereum/client-go:release-${GETH_VERSION} as prepare-geth
FROM ipfs/go-ipfs:v${IPFS_VERSION} as prepare-ipfs
FROM alpine as prepare-bitcoin
ARG BITCOIN_CLI_VERSION
# Download checksums
ADD https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_CLI_VERSION}/SHA256SUMS ./
# Download archive
ADD https://bitcoincore.org/bin/bitcoin-core-${BITCOIN_CLI_VERSION}/bitcoin-${BITCOIN_CLI_VERSION}-x86_64-linux-gnu.tar.gz ./
# Verify that downloaded archive matches exactly the hash that's provided
RUN grep " bitcoin-${BITCOIN_CLI_VERSION}-x86_64-linux-gnu.tar.gz\$" SHA256SUMS | sha256sum -c -
# Extract
RUN tar -xzf "bitcoin-${BITCOIN_CLI_VERSION}-x86_64-linux-gnu.tar.gz"
# minimal
# ----------------------------------------------------------------------------
FROM ghcr.io/linuxserver/baseimage-ubuntu:focal as minimal
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
LABEL org.opencontainers.image.created="${BUILD_DATE}"
LABEL org.opencontainers.image.revision="${COMMIT}"
LABEL org.opencontainers.image.ref.name="${COMMIT}"
LABEL org.opencontainers.image.base.name="ghcr.io/linuxserver/baseimage-ubuntu:focal"
LABEL org.opencontainers.image.url="https://github.com/fluencelabs/node-distro"
LABEL org.opencontainers.image.version="${VERSION}"
LABEL org.opencontainers.image.vendor="fluencelabs"
LABEL maintainer="fluencelabs"
LABEL org.opencontainers.image.authors="fluencelabs"
LABEL org.opencontainers.image.title="Fluence Node"
LABEL org.opencontainers.image.description="Minimal image containing only Fluence Node itself"
LABEL dev.fluence.image.builtins="${SERVICES_VERSION}"
ENV RUST_LOG="info,aquamarine=warn,tokio_threadpool=info,tokio_reactor=info,mio=info,tokio_io=info,soketto=info,yamux=info,multistream_select=info,libp2p_secio=info,libp2p_websocket::framed=info,libp2p_ping=info,libp2p_core::upgrade::apply=info,libp2p_kad::kbucket=info,cranelift_codegen=info,wasmer_wasi=info,cranelift_codegen=info,wasmer_wasi=info"
ENV RUST_BACKTRACE="1"
## set /run_fluence as the CMD binary
ENV S6_CMD_ARG0="/run_fluence"
# fluence builtins default envs
ENV FLUENCE_ENV_AQUA_IPFS_EXTERNAL_API_MULTIADDR=/ip4/127.0.0.1/tcp/5001
ENV FLUENCE_ENV_AQUA_IPFS_LOCAL_API_MULTIADDR=/ip4/127.0.0.1/tcp/5001
ENV FLUENCE_ENV_AQUA_IPFS_EXTERNAL_SWARM_MULTIADDR=/ip4/127.0.0.1/tcp/4001
RUN \
echo "**** install packages ****" && \
apt-get update && \
apt-get install -y --no-install-recommends \
jq \
less \
logrotate \
curl && \
echo "**** cleanup ****" && \
apt-get clean && \
rm -rf \
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/*
# download fluence and builtins
RUN --mount=type=bind,source=fluence,target=/fluence /fluence/download_fluence.sh /fluence/fluence.json
RUN --mount=type=bind,source=fluence,target=/fluence /fluence/download_builtins.sh /fluence/services.json
# copy default fluence config
COPY fluence/Config.default.toml /.fluence/v1/Config.toml
# copy s6 configs
COPY s6/minimal/ /
# ipfs
# ----------------------------------------------------------------------------
FROM minimal as ipfs
LABEL org.opencontainers.image.description="Fluence Node bundled with IPFS"
LABEL dev.fluence.bundles.ipfs="${IPFS_VERSION}"
ENV IPFS_PATH=/config/ipfs IPFS_LOG_DIR=/log/ipfs IPFS_LOGGING_FMT=nocolor
# copy IPFS binary
COPY --from=prepare-ipfs /usr/local/bin/ipfs /usr/bin/ipfs
# copy s6 configs
COPY s6/ipfs/ /
# expose IPFS node port
EXPOSE 5001
# rich
# ----------------------------------------------------------------------------
FROM ipfs as rich
ARG CERAMIC_VERSION
ARG GLAZED_VERSION
ARG GETH_VERSION
ARG BITCOIN_CLI_VERSION
LABEL org.opencontainers.image.description="Fluence Node bundled with IPFS, Ceramic CLI and other tools"
LABEL dev.fluence.image.bundles.ceramic="${CERAMIC_VERSION}"
LABEL dev.fluence.image.bundles.glazed="${GLAZED_VERSION}"
LABEL dev.fluence.image.bundles.bitcoin_cli="${BITCOIN_CLI_VERSION}"
LABEL dev.fluence.image.bundles.geth="${GETH_VERSION}"
# add nodejs 16.x repo
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor > /usr/share/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x focal main" > /etc/apt/sources.list.d/nodesource.list
RUN \
echo "**** install packages ****" && \
apt-get update && \
apt-get install -y --no-install-recommends \
musl \
nodejs && \
echo "**** cleanup ****" && \
apt-get clean && \
rm -rf \
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/*
# install ceramic and glaze
RUN npm install --cache /cache --global \
@ceramicnetwork/cli@$CERAMIC_VERSION \
@glazed/cli@$GLAZED_VERSION \
&& rm -rf /cache
# copy geth
COPY --from=prepare-geth /usr/local/bin/geth /usr/bin/geth
# copy bitcoin-cli
COPY --from=prepare-bitcoin /bitcoin-${BITCOIN_CLI_VERSION}/bin/bitcoin-cli /usr/bin/bitcoin-cli
# copy s6 configs
COPY s6/rich/ /