Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Jul 6, 2024
1 parent 77450cb commit 2880cd0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches:
- main
- docker
- 'releases/**'
- 'release/**'
tags:
- '**'

Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/subcoin-project/subcoin-node
ghcr.io/subcoin-project/subcoin
tags: |
type=ref,event=tag
type=ref,event=branch
Expand Down
34 changes: 16 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@ ARG SUBSTRATE_CLI_GIT_COMMIT_HASH
# Incremental compilation here isn't helpful
ENV CARGO_INCREMENTAL=0

WORKDIR /subcoin
WORKDIR /src

RUN \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
protobuf-compiler \
clang \
cmake \
curl \
git \
llvm \
clang \
cmake \
protobuf-compiler \
make && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Copy the source code
COPY . .

RUN /root/.cargo/bin/cargo build --locked --profile=$PROFILE
RUN /root/.cargo/bin/cargo build --locked --bin subcoin \
--profile=$PROFILE \
--target $(uname -p)-unknown-linux-gnu

# This is the 2nd stage: a very small image where we copy the binary.
FROM docker.io/library/ubuntu:22.04
Expand All @@ -35,25 +37,21 @@ LABEL description="Multistage Docker image for Subcoin Node" \
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"
image.documentation="https://subcoin-project.github.io/subcoin" \
org.opencontainers.image.description="Multistage Docker image for Subcoin Node" \
org.opencontainers.image.source="https://github.com/subcoin-project/subcoin"

ARG PROFILE=production

# Copy the node binary.
COPY --from=builder /subcoin/target/$PROFILE/subcoin /usr/local/bin
COPY --from=builder /src/target/$PROFILE/subcoin /subcoin

RUN mkdir /node-data && chown nobody:nogroup /node-data

RUN useradd -m -u 1000 -U -s /bin/sh -d /node-dev node-dev && \
mkdir -p /chain-data /node-dev/.local/share && \
chown -R node-dev:node-dev /chain-data && \
ln -s /chain-data /node-dev/.local/share/subcoin && \
# unclutter and minimize the attack surface
rm -rf /usr/bin /usr/sbin && \
# check if executable works in this container
/usr/local/bin/subcoin --help
VOLUME ["/node-data"]

USER node-dev
USER nobody:nogroup

EXPOSE 30333 9933 9944 9615
VOLUME ["/chain-data"]

ENTRYPOINT ["/usr/local/bin/subcoin"]
ENTRYPOINT ["/subcoin"]

0 comments on commit 2880cd0

Please sign in to comment.