Skip to content

Commit

Permalink
update Dockerfile (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
frank0528 authored Aug 14, 2024
1 parent 95f1619 commit 3e4e4ba
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**target*
.github/
38 changes: 27 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
FROM ubuntu:22.04
FROM docker.io/paritytech/ci-unified:latest AS builder

# RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list
WORKDIR /DeepBrainChain-MainChain
COPY . .

RUN apt-get -y update
RUN apt-get -y install ca-certificates curl git gnupg cmake pkg-config libssl-dev git gcc build-essential clang libclang-dev gcc-12 g++-12 protobuf-compiler
RUN cargo fetch
RUN cargo build --locked --release

# ENV RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
# ENV RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
ENV PATH="/root/.cargo/bin:${PATH}"
# =============

COPY . /DeepBrainChain-MainChain
WORKDIR /DeepBrainChain-MainChain
FROM docker.io/parity/base-bin:latest
LABEL maintainer="DeepBrainChain Developers"

COPY --from=builder /DeepBrainChain-MainChain/target/release/dbc-chain /usr/local/bin

USER root
ARG USERNAME=dbc
RUN useradd -m -u 1001 -U -s /bin/sh -d /$USERNAME $USERNAME && \
mkdir -p /$USERNAME/data /$USERNAME/.local/share && \
chown -R $USERNAME:$USERNAME /$USERNAME/data && \
ln -s /$USERNAME/data /$USERNAME/.local/share/dbc-chain && \
# unclutter and minimize the attack surface
# rm -rf /usr/bin /usr/sbin && \
# check if executable works in this container
/usr/local/bin/dbc-chain --version

USER $USERNAME

EXPOSE 30333 9933 9944 9615
VOLUME ["/$USERNAME/data"]

RUN cargo build --release
ENTRYPOINT ["/usr/local/bin/dbc-chain"]

0 comments on commit 3e4e4ba

Please sign in to comment.