mirror of
https://github.com/fluencelabs/node-distro
synced 2024-12-04 23:30:17 +00:00
Build several flavors of Fluence Node docker image (#43)
This commit is contained in:
parent
16ab2638bc
commit
b6ab8ddbd8
94
.github/workflows/container.yml
vendored
94
.github/workflows/container.yml
vendored
@ -1,4 +1,4 @@
|
||||
name: Publish Container
|
||||
name: Publish containers
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@ -21,70 +21,76 @@ on:
|
||||
description: 'Fluence binary SHA256 hash'
|
||||
required: false
|
||||
|
||||
env:
|
||||
RUN_NUMBER: ${{ github.run_number }}
|
||||
DOCKER_BUILDKIT: 1
|
||||
|
||||
jobs:
|
||||
build-publish:
|
||||
name: Build and publish ${{ github.event.inputs.container_tag || 'latest' }}
|
||||
prepare:
|
||||
name: "Prepare"
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CONTAINER_TAG: ${{ github.event.inputs.container_tag || 'latest' }}
|
||||
UPDATE_FLUENCE: ${{ github.event.inputs.update_fluence == 'true' || github.event.inputs.container_tag == '' }}
|
||||
|
||||
|
||||
outputs:
|
||||
build_date: "${{ steps.build_date.outputs.date }}"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set build date
|
||||
id: build_date
|
||||
run: echo "::set-output name=date::$(date '+%Y-%m-%dT%H:%M:%S%:z')"
|
||||
|
||||
build:
|
||||
name: Build and publish ${{ matrix.package }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: prepare
|
||||
|
||||
env:
|
||||
TAG: ${{ github.event.inputs.container_tag || 'latest' }}
|
||||
UPDATE_FLUENCE: ${{ github.event.inputs.update_fluence == 'true' || github.event.inputs.container_tag == '' }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
package:
|
||||
- minimal
|
||||
- ipfs
|
||||
- rich
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Update Fluence in fluence.json to ${{ github.event.inputs.version }}
|
||||
if: ${{ env.UPDATE_FLUENCE != 'false' }}
|
||||
if: env.UPDATE_FLUENCE != 'false'
|
||||
run: |
|
||||
echo '
|
||||
cat <<FLUENCE > fluence/fluence.json
|
||||
{
|
||||
"version": "${{ github.event.inputs.version }}",
|
||||
"url": "${{ github.event.inputs.url }}",
|
||||
"sha256": "${{ github.event.inputs.sha256 }}"
|
||||
}
|
||||
' > fluence/fluence.json
|
||||
|
||||
### Prepare docker & login to Dockerhub
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
FLUENCE
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Determine container tags
|
||||
run: |
|
||||
TAG="${{ env.CONTAINER_TAG }}"
|
||||
RUN="${{ github.run_number }}"
|
||||
TAGS=fluencelabs/node:${TAG},fluencelabs/node:${TAG}_v${RUN}
|
||||
TAGS=$TAGS,fluencelabs/fluence:${TAG},fluencelabs/fluence:${TAG}_v${RUN}
|
||||
|
||||
echo "TAGS=$TAGS" | tee -a $GITHUB_ENV
|
||||
echo "BUILD_DATE=$(date '+%Y-%m-%dT%H:%M:%S%:z')"
|
||||
|
||||
### Build and push docker image
|
||||
- name: Build and push ${{ env.TAGS }}
|
||||
id: docker_publish
|
||||
uses: docker/build-push-action@v2
|
||||
- name: Build and push ${{ matrix.package }}
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
push: true
|
||||
tags: "${{ env.TAGS }}"
|
||||
target: ${{ matrix.package }}
|
||||
tags: |
|
||||
fluencelabs/fluence:${{ matrix.package }}_${{ env.TAG }}
|
||||
fluencelabs/fluence:${{ matrix.package }}_${{ env.TAG }}_${{ env.RUN_NUMBER }}
|
||||
build-args: |
|
||||
COMMIT=${{ github.sha }}
|
||||
BUILD_DATE=${{ env.BUILD_DATE }}
|
||||
RUN_NUMBER=${{ github.run_number }}
|
||||
TAG=${{ env.CONTAINER_TAG }}
|
||||
BUILD_DATE=${{ needs.prepare.outputs.build_date }}
|
||||
RUN_NUMBER=${{ env.RUN_NUMBER }}
|
||||
TAG=${{ env.TAG }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
178
.github/workflows/release.yml
vendored
178
.github/workflows/release.yml
vendored
@ -5,113 +5,149 @@ on:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
env:
|
||||
RUN_NUMBER: ${{ github.run_number }}
|
||||
DOCKER_BUILDKIT: 1
|
||||
FORCE_COLOR: 1
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: "release"
|
||||
prepare:
|
||||
name: "Prepare"
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
outputs:
|
||||
build_date: "${{ steps.build_date.outputs.date }}"
|
||||
release_version: "${{ steps.release_version.outputs.version }}"
|
||||
|
||||
steps:
|
||||
- name: Set build date
|
||||
id: build_date
|
||||
run: echo "::set-output name=date::$(date '+%Y-%m-%dT%H:%M:%S%:z')"
|
||||
|
||||
- set: Set release version
|
||||
id: release_version
|
||||
run: echo "::set-output name=version::$(echo ${GITHUB_REF#refs/*/})"
|
||||
|
||||
build:
|
||||
name: Build and push ${{ matrix.package }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: prepare
|
||||
|
||||
env:
|
||||
BUILD_DATE: ${{ needs.prepare.outputs.build_date }}
|
||||
RELEASE_VERSION: ${{ needs.prepare.outputs.release_version }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
package:
|
||||
- minimal
|
||||
- ipfs
|
||||
- rich
|
||||
|
||||
steps:
|
||||
### Setup
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set RELEASE_VERSION
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
|
||||
### Prepare docker & login to Dockerhub
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Determine container tags
|
||||
run: |
|
||||
RUN="${{ github.run_number }}"
|
||||
VERSION="${{ env.RELEASE_VERSION }}"
|
||||
TAGS=fluencelabs/node:${VERSION},fluencelabs/node:${VERSION}_${RUN},fluencelabs/node:latest,fluencelabs/fluence:${VERSION},fluencelabs/fluence:${VERSION}_${RUN},fluencelabs/fluence:latest
|
||||
|
||||
echo "TAGS=$TAGS" | tee -a $GITHUB_ENV
|
||||
echo "BUILD_DATE=$(date '+%Y-%m-%dT%H:%M:%S%:z')"
|
||||
|
||||
### Build and push docker image
|
||||
- name: Build and push
|
||||
id: docker_publish
|
||||
uses: docker/build-push-action@v2
|
||||
- name: Build and push ${{ matrix.package }}
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile
|
||||
push: true
|
||||
tags: "${{ env.TAGS }}"
|
||||
target: ${{ matrix.package }}
|
||||
tags: |
|
||||
fluencelabs/fluence:${{ matrix.package }}
|
||||
fluencelabs/fluence:${{ matrix.package }}_${{ env.RELEASE_VERSION }}
|
||||
fluencelabs/fluence:${{ matrix.package }}_${{ env.RELEASE_VERSION }}_${{ env.RUN_NUMBER }}
|
||||
build-args: |
|
||||
COMMIT=${{ github.sha }}
|
||||
BUILD_DATE=${{ env.BUILD_DATE }}
|
||||
RUN_NUMBER=${{ github.run_number }}
|
||||
RUN_NUMBER=${{ env.RUN_NUMBER }}
|
||||
TAG=${{ env.RELEASE_VERSION }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
### Create GitHub release
|
||||
- name: Build Changelog
|
||||
id: github_release
|
||||
uses: mikepenz/release-changelog-builder-action@v1
|
||||
- name: Build and push ${{ matrix.package }}
|
||||
if: matrix.package == 'ipfs'
|
||||
uses: docker/build-push-action@v3
|
||||
with:
|
||||
configuration: ".github/workflows/changelog_config.json"
|
||||
context: .
|
||||
push: true
|
||||
target: ${{ matrix.package }}
|
||||
tags: |
|
||||
fluencelabs/fluence:latest
|
||||
build-args: |
|
||||
COMMIT=${{ github.sha }}
|
||||
BUILD_DATE=${{ env.BUILD_DATE }}
|
||||
RUN_NUMBER=${{ env.RUN_NUMBER }}
|
||||
TAG=${{ env.RELEASE_VERSION }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
release:
|
||||
name: "Release"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs:
|
||||
- prepare
|
||||
- build
|
||||
|
||||
env:
|
||||
RELEASE_VERSION: ${{ needs.prepare.outputs.release_version }}
|
||||
|
||||
steps:
|
||||
- name: Build changelog
|
||||
id: github_release
|
||||
uses: mikepenz/release-changelog-builder-action@v3
|
||||
with:
|
||||
configuration: ".github/misc/changelog_config.json"
|
||||
commitMode: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Parse metadata from docker publish
|
||||
id: metadata
|
||||
uses: actions/github-script@v4
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
result-encoding: string
|
||||
script: |
|
||||
try {
|
||||
let metadataRaw = `${{ steps.docker_publish.outputs.metadata }}`;
|
||||
let metadata = JSON.parse(metadataRaw);
|
||||
let imageTags = metadata['image.name'].split(",");
|
||||
let tagString = imageTags.reduce(
|
||||
(acc, tag) => { return `${acc}\n- ${tag}` },
|
||||
""
|
||||
)
|
||||
console.log(tagString);
|
||||
return tagString;
|
||||
} catch (e) {
|
||||
console.log("Err: " + e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
- name: Release
|
||||
id: release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
name: Fluence Node ${{ env.RELEASE_VERSION }}
|
||||
tag_name: ${{ env.RELEASE_VERSION }}
|
||||
body: |
|
||||
${{steps.github_release.outputs.changelog}}
|
||||
${{ steps.github_release.outputs.changelog }}
|
||||
|
||||
## Docker tags
|
||||
${{steps.metadata.outputs.result}}
|
||||
|
||||
### ipfs
|
||||
Contains Fluence Rust Peer and builtin IPFS deaemon.
|
||||
|
||||
fluencelabs/fluence:latest
|
||||
fluencelabs/fluence:${{ env.RELEASE_VERSION }}
|
||||
fluencelabs/fluence:ipfs
|
||||
fluencelabs/fluence:ipfs_${{ env.RELEASE_VERSION }}
|
||||
fluencelabs/fluence:ipfs_${{ env.RELEASE_VERSION }}_${{ env.RUN_NUMBER }}
|
||||
|
||||
## minimal
|
||||
Contains Fluence Peer only.
|
||||
|
||||
fluencelabs/fluence:minimal
|
||||
fluencelabs/fluence:minimal_${{ env.RELEASE_VERSION }}
|
||||
fluencelabs/fluence:minimal_${{ env.RELEASE_VERSION }}_${{ env.RUN_NUMBER }}
|
||||
|
||||
## rich
|
||||
Contains Fluence Rust Peer, IPFS, ceramic cli, bitcoin cli and geth cli.
|
||||
|
||||
fluencelabs/fluence:rich
|
||||
fluencelabs/fluence:rich_${{ env.RELEASE_VERSION }}
|
||||
fluencelabs/fluence:rich_${{ env.RELEASE_VERSION }}_${{ env.RUN_NUMBER }}
|
||||
|
||||
draft: false
|
||||
prerelease: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
|
4
.github/workflows/update_fluence.yml
vendored
4
.github/workflows/update_fluence.yml
vendored
@ -27,13 +27,13 @@ jobs:
|
||||
|
||||
- name: Update Fluence in fluence.json to ${{ github.event.inputs.version }}
|
||||
run: |
|
||||
echo '
|
||||
cat <<FLUENCE > fluence/fluence.json
|
||||
{
|
||||
"version": "${{ github.event.inputs.version }}",
|
||||
"url": "${{ github.event.inputs.url }}",
|
||||
"sha256": "${{ github.event.inputs.sha256 }}"
|
||||
}
|
||||
' > fluence/fluence.json
|
||||
FLUENCE
|
||||
|
||||
- name: Commit updated fluence.json
|
||||
uses: EndBug/add-and-commit@v7
|
||||
|
172
Dockerfile
172
Dockerfile
@ -1,28 +1,49 @@
|
||||
### NOTE: original linuxserver.org docker-ipfs image also builds & runs migrations.
|
||||
### If needed, go to https://github.com/linuxserver/docker-ipfs to see how it's done.
|
||||
|
||||
ARG IPFS=v0.9.0
|
||||
ARG CERAMIC_VERSION=2.3.x
|
||||
ARG GLAZED_VERSION=0.2.x
|
||||
|
||||
FROM ipfs/go-ipfs:${IPFS} as ipfs
|
||||
|
||||
FROM ghcr.io/linuxserver/baseimage-ubuntu:focal
|
||||
|
||||
ARG COMMIT
|
||||
ARG SERVICES_VERSION
|
||||
ARG RUN_NUMBER
|
||||
ARG TAG
|
||||
ARG BUILD_DATE
|
||||
LABEL commit="${commit}"
|
||||
LABEL build_version="Fluence Node version=${TAG} date=${BUILD_DATE} ci_run=${RUN_NUMBER} builtins=${SERVICES_VERSION} IPFS=${IPFS}"
|
||||
LABEL maintainer="fluencelabs"
|
||||
|
||||
# environment
|
||||
ENV IPFS_PATH=/config/ipfs
|
||||
ENV IPFS_LOGGING_FMT=nocolor
|
||||
# https://github.com/ceramicnetwork/js-ceramic/issues/2245
|
||||
ENV CERAMIC_ROOT_PATH=/.ceramic
|
||||
ARG IPFS_VERSION=0.9.0
|
||||
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
|
||||
@ -33,25 +54,79 @@ 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
|
||||
|
||||
# install nodejs 16.x
|
||||
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 \
|
||||
nodejs \
|
||||
jq \
|
||||
less \
|
||||
logrotate \
|
||||
curl && \
|
||||
echo "**** cleanup ****" && \
|
||||
apt-get clean && \
|
||||
rm -rf \
|
||||
/tmp/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/*
|
||||
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 \
|
||||
@ -59,28 +134,11 @@ RUN npm install --cache /cache --global \
|
||||
@glazed/cli@$GLAZED_VERSION \
|
||||
&& rm -rf /cache
|
||||
|
||||
# download fluence & builtin services
|
||||
COPY fluence/services.json /services.json
|
||||
COPY fluence/download_builtins.sh /download_builtins.sh
|
||||
RUN /download_builtins.sh
|
||||
# copy geth
|
||||
COPY --from=prepare-geth /usr/local/bin/geth /usr/bin/geth
|
||||
|
||||
# TODO: copy binary to /usr/bin & state to /config/fluence
|
||||
COPY fluence/Config.default.toml /.fluence/v1/Config.toml
|
||||
COPY fluence/fluence.json /fluence.json
|
||||
COPY fluence/download_fluence.sh /download_fluence.sh
|
||||
RUN /download_fluence.sh
|
||||
# copy bitcoin-cli
|
||||
COPY --from=prepare-bitcoin /bitcoin-${BITCOIN_CLI_VERSION}/bin/bitcoin-cli /usr/bin/bitcoin-cli
|
||||
|
||||
# copy sidecars
|
||||
COPY --from=ipfs /usr/local/bin/ipfs /usr/bin/ipfs
|
||||
|
||||
# copy configs
|
||||
# NOTE: copy configs should be after installing packages because
|
||||
# configs may replace default configs of installed packages
|
||||
COPY s6/root/ /
|
||||
|
||||
COPY fluence/run_fluence /run_fluence
|
||||
|
||||
# ports and volumes
|
||||
EXPOSE 5001
|
||||
VOLUME ["/config"]
|
||||
VOLUME ["/.fluence"]
|
||||
# copy s6 configs
|
||||
COPY s6/rich/ /
|
||||
|
44
README.md
44
README.md
@ -4,13 +4,51 @@ The distributive and packaging of the Fluence node.
|
||||
|
||||
Currently provides Network Dashboard as a side-car.
|
||||
|
||||
## Image tags
|
||||
|
||||
| Container flavor | IPFS daemon | services | binaries |
|
||||
| ---------------- | ----------- | ------------------------------------------ | ------------------------------------------ |
|
||||
| minimal | ❌ | aqua-ipfs, aqua-dht, trust-graph, registry | curl |
|
||||
| ipfs | ✅ | aqua-ipfs, aqua-dht, trust-graph, registry | curl, ipfs |
|
||||
| rich | ✅ | aqua-ipfs, aqua-dht, trust-graph, registry | curl, ipfs, ceramic, bitcoin cli, geth cli |
|
||||
|
||||
### minimal
|
||||
|
||||
Contains Fluence Node itself and some builtin services:
|
||||
|
||||
- [aqua-ipfs](https://github.com/fluencelabs/aqua-ipfs)
|
||||
- aqua-dht
|
||||
- [trust-graph](https://github.com/fluencelabs/trust-graph)
|
||||
- [registry](https://github.com/fluencelabs/registry)
|
||||
|
||||
For those who want to run IPFS node separately. Serves as a base image for all
|
||||
other image flavours.
|
||||
|
||||
### ipfs
|
||||
|
||||
Fluence Node packaged with
|
||||
[IPFS node](https://docs.ipfs.io/how-to/command-line-quick-start/#take-your-node-online)
|
||||
running inside container.
|
||||
|
||||
### rich
|
||||
|
||||
Fluence Node packaged with IPFS node,
|
||||
[Ceramic](https://developers.ceramic.network/learn/welcome/) CLI and some other
|
||||
binaries like bitcoin-cli or
|
||||
[geth](https://geth.ethereum.org/docs/interface/command-line-options).
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environmental variables
|
||||
|
||||
| variable | required | description |
|
||||
| -------------- | -------- | ---------------------- |
|
||||
| `CERAMIC_HOST` | | ceramic daemon address |
|
||||
| variable | default | description |
|
||||
| ------------------------------------------------ | -------------- | ------------------------------------------- |
|
||||
| `CERAMIC_HOST` | | ceramic daemon address |
|
||||
| `IPFS_PATH` | `/config/ipfs` | IPFS node data directory |
|
||||
| `IPFS_LOG_PATH` | `/log/ipfs` | directory where IPFS will store its logs |
|
||||
| `FLUENCE_ENV_AQUA_IPFS_EXTERNAL_API_MULTIADDR` | | IPFS node address used by aqua-ipfs builtin |
|
||||
| `FLUENCE_ENV_AQUA_IPFS_LOCAL_API_MULTIADDR` | | IPFS node address used by aqua-ipfs builtin |
|
||||
| `FLUENCE_ENV_AQUA_IPFS_EXTERNAL_SWARM_MULTIADDR` | | IPFS node address used by aqua-ipfs builtin |
|
||||
|
||||
## How to run
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o pipefail -o errexit -o nounset
|
||||
|
||||
CONFIG="${1:-services.json}"
|
||||
|
||||
BUILTINS_DIR=/builtins/
|
||||
TMP_BUILTINS=./tmp/builtins
|
||||
|
||||
@ -9,7 +11,7 @@ mkdir -p $TMP_BUILTINS
|
||||
|
||||
jq -r '
|
||||
to_entries | .[] | .key, .value.url, .value.sha256, .value.version
|
||||
' services.json |
|
||||
' $CONFIG |
|
||||
while
|
||||
read -r name
|
||||
read -r url
|
||||
|
@ -1,7 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o pipefail -o errexit -o nounset
|
||||
|
||||
jq -r '.url, .sha256, .version' fluence.json |
|
||||
CONFIG="${1:-fluence.json}"
|
||||
|
||||
jq -r '.url, .sha256, .version' $CONFIG |
|
||||
while
|
||||
IFS=''
|
||||
read -r url
|
||||
@ -10,13 +12,13 @@ jq -r '.url, .sha256, .version' fluence.json |
|
||||
do
|
||||
echo "*** download $version ***"
|
||||
# TODO: use --fail-with-body
|
||||
curl -sL --fail $url -o /fluence || (
|
||||
curl -sL --fail $url -o /usr/bin/fluence || (
|
||||
echo "failed to download $url" >&2
|
||||
exit 1
|
||||
)
|
||||
echo "$sha256 /fluence" | sha256sum --check --status || (
|
||||
echo "$sha256 /usr/bin/fluence" | sha256sum --check --status || (
|
||||
echo "incorrect SHA256" >&2
|
||||
exit 1
|
||||
)
|
||||
chmod +x /fluence
|
||||
chmod +x /usr/bin/fluence
|
||||
done
|
||||
|
@ -1,7 +1,5 @@
|
||||
|
||||
{
|
||||
"version": "v1.9.19",
|
||||
"url": "https://github.com/fluencelabs/fluence/releases/download/v1.9.19/particle-node",
|
||||
"sha256": "0c46edd880fe5e8bb4b003076cfe8e8bc9457613f0c5e733457edb9724707cdf"
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# IPFS_PATH is set to /config/ipfs in Dockerfile
|
||||
# ipfs config
|
||||
if [ ! -d "/config/ipfs" ]; then
|
||||
if [[ ! -d "$IPFS_PATH" ]]; then
|
||||
ipfs init
|
||||
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
|
||||
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
|
||||
@ -12,20 +10,14 @@ if [ ! -d "/config/ipfs" ]; then
|
||||
# remove default bootstraps
|
||||
ipfs bootstrap rm --all
|
||||
|
||||
# enable Private Network feature by copying swarm.key to $IPFS_HOME
|
||||
# enable Private Network feature by copying swarm.key to $IPFS_PATH
|
||||
# https://github.com/ipfs/go-ipfs/blob/master/docs/experimental-features.md#private-networks
|
||||
cp /defaults/ipfs_preshared_swarm.key /config/ipfs/swarm.key
|
||||
cp /defaults/ipfs_preshared_swarm.key $IPFS_PATH/swarm.key
|
||||
|
||||
# to check that Private Network is enabled, look for a line
|
||||
# 'Swarm is limited to private network of peers with the swarm key'
|
||||
# in IPFS logs @ /config/log/ipfs
|
||||
# in IPFS logs
|
||||
fi
|
||||
|
||||
# make our folders
|
||||
mkdir -p \
|
||||
/config/log/ipfs \
|
||||
/run
|
||||
|
||||
# permissions
|
||||
chown -R abc:abc /config
|
||||
chown -R abc:abc /.fluence
|
||||
mkdir -p $IPFS_PATH $IPFS_LOG_DIR
|
||||
chown -R abc:abc $IPFS_PATH $IPFS_LOG_DIR
|
4
s6/root/etc/services.d/ipfs/log/run → s6/ipfs/etc/services.d/ipfs/log/run
Normal file → Executable file
4
s6/root/etc/services.d/ipfs/log/run → s6/ipfs/etc/services.d/ipfs/log/run
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
#!/bin/execlineb -P
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
# s6-setuidgid abc - run as a user abc (unprivileged)
|
||||
|
||||
@ -7,4 +7,4 @@
|
||||
# S30000000 - keep only 30 MB of rotated (and compressed) logs
|
||||
# T - prepend timestamp to each line
|
||||
# !"gzip -nq9" - compresses logs on rotation
|
||||
s6-setuidgid abc s6-log n30 s10000000 S30000000 T !"gzip -nq9" /config/log/ipfs
|
||||
s6-setuidgid abc s6-log n30 s10000000 S30000000 T !"gzip -nq9" $IPFS_LOG_DIR
|
0
s6/root/etc/services.d/ipfs/run → s6/ipfs/etc/services.d/ipfs/run
Normal file → Executable file
0
s6/root/etc/services.d/ipfs/run → s6/ipfs/etc/services.d/ipfs/run
Normal file → Executable file
4
s6/minimal/etc/cont-init.d/30-fluence
Normal file
4
s6/minimal/etc/cont-init.d/30-fluence
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
mkdir -p /.fluence
|
||||
chown -R abc:abc /.fluence
|
@ -1,8 +1,11 @@
|
||||
#!/usr/bin/execlineb -s0
|
||||
# '-s0' defines '$@' to hold all positional parameters
|
||||
|
||||
# import ENV from container
|
||||
with-contenv
|
||||
|
||||
# remove old HOME variable from the environment, so the daemon isn't confused by it
|
||||
# see https://github.com/fluencelabs/node-distro/issues/14 for more details
|
||||
unexport HOME
|
||||
# 'setuidgid abc' runs '/fluence' as user 'abc'
|
||||
s6-setuidgid abc /fluence $@
|
||||
# 'setuidgid abc' runs '/usr/bin/fluence' as user 'abc'
|
||||
s6-setuidgid abc /usr/bin/fluence $@
|
Loading…
Reference in New Issue
Block a user