From c092e3c46ceb5f62961b7d4d55d9bdb077524db5 Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Fri, 5 Jul 2024 21:54:09 +0800 Subject: [PATCH] . --- .github/workflows/docker.yml | 6 +----- Dockerfile | 37 ++++++++++++++++++---------------- crates/subcoin-node/src/cli.rs | 2 +- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 20fb5c4f..37a59a8c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -5,14 +5,10 @@ on: workflow_dispatch: push: branches: - - '**' + - ['main', 'v*', 'docker'] tags: - '**' -# Incremental compilation here isn't helpful -env: - CARGO_INCREMENTAL: 0 - jobs: container-linux: runs-on: ubuntu-22.04 diff --git a/Dockerfile b/Dockerfile index 4c0d7db3..192634fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,11 @@ -# This is an example build stage for the node template. Here we create the binary in a temporary image. - -# This is a base image to build substrate nodes -FROM ubuntu:22.04 as builder +# This is a base image to build Subcoin node +FROM ubuntu:22.04 AS builder ARG PROFILE=production +ARG SUBSTRATE_CLI_GIT_COMMIT_HASH + +# Incremental compilation here isn't helpful +ENV CARGO_INCREMENTAL=0 WORKDIR /subcoin @@ -18,26 +20,27 @@ RUN \ clang \ cmake \ make && \ - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - -RUN /root/.cargo/bin/rustup target add wasm32-unknown-unknown + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +# Copy the source code COPY . . -RUN cargo build --locked --profile=production +RUN /root/.cargo/bin/cargo build --locked --profile=$PROFILE -# This is the 2nd stage: a very small image where we copy the binary." +# This is the 2nd stage: a very small image where we copy the binary. FROM docker.io/library/ubuntu:22.04 -LABEL description="Multistage Docker image for Substrate Node Template" \ +LABEL description="Multistage Docker image for Subcoin Node" \ image.type="builder" \ - image.authors="you@email.com" \ - image.vendor="Substrate Developer Hub" \ - image.description="Multistage Docker image for Substrate Node Template" \ - image.source="https://github.com/substrate-developer-hub/substrate-subcoin" \ - image.documentation="https://github.com/substrate-developer-hub/substrate-subcoin" + image.authors="xuliuchengxlc@email.com" \ + image.vendor="Subcoin Contributors" \ + image.description="Multistage Docker image for Subnode Node" \ + image.source="https://github.com/subcoin-project/subcoin" \ + image.documentation="https://subcoin-project.github.io/subcoin" + +ARG PROFILE=production # Copy the node binary. -COPY --from=builder /subcoin/target/production/subcoin /usr/local/bin +COPY --from=builder /subcoin/target/$PROFILE/subcoin /usr/local/bin RUN useradd -m -u 1000 -U -s /bin/sh -d /node-dev node-dev && \ mkdir -p /chain-data /node-dev/.local/share && \ @@ -46,7 +49,7 @@ RUN useradd -m -u 1000 -U -s /bin/sh -d /node-dev node-dev && \ # unclutter and minimize the attack surface rm -rf /usr/bin /usr/sbin && \ # check if executable works in this container - /usr/local/bin/subcoin --version + /usr/local/bin/subcoin --help USER node-dev diff --git a/crates/subcoin-node/src/cli.rs b/crates/subcoin-node/src/cli.rs index 7174ec28..0b388858 100644 --- a/crates/subcoin-node/src/cli.rs +++ b/crates/subcoin-node/src/cli.rs @@ -10,7 +10,7 @@ use sc_service::PartialComponents; #[derive(Debug, clap::Subcommand)] pub enum Command { - /// Import blocks. + /// Import blocks from bitcoind database. ImportBlocks(ImportBlocks), /// Validate blocks.