From 068c009f6270a5be55d9316ee09e9840bf01d96d Mon Sep 17 00:00:00 2001 From: zhangsoledad <787953403@qq.com> Date: Mon, 3 Dec 2018 18:33:19 +0800 Subject: [PATCH] feat: dockerfile for hub --- .dockerignore | 3 +++ Makefile | 5 ++++- docker/hub/Dockerfile | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 docker/hub/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..9a9fc92644 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +**/*.rs +target/ +!target/release/ckb diff --git a/Makefile b/Makefile index 0ad0bf612f..d837c802e4 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,9 @@ security-audit: @cargo audit --version || cargo install cargo-audit @cargo audit -.PHONY: build build-integration-test +docker: build + docker build -f docker/hub/Dockerfile -t ckb:latest . + +.PHONY: build build-integration-test docker .PHONY: fmt test clippy proto doc doc-deps check stats .PHONY: ci ci-quick info security-audit diff --git a/docker/hub/Dockerfile b/docker/hub/Dockerfile new file mode 100644 index 0000000000..aca0785b82 --- /dev/null +++ b/docker/hub/Dockerfile @@ -0,0 +1,37 @@ +FROM ubuntu:bionic +LABEL description="Nervos CKB is a public permissionless blockchain, the common knowledge layer of Nervos network." +LABEL maintainer="Nervos Core Dev " + +#build arg +ARG DATADIR=/usr/local/share/ckb +ENV DATADIR ${DATADIR} + +#useradd +RUN groupadd -g 1000 ckb && useradd -m -u 1000 -g ckb -s /bin/sh ckb + +WORKDIR ${DATADIR} + +#apt +RUN apt update && apt install -y --no-install-recommends openssl1.0 libssl1.0 + +#cleanup +RUN apt autoremove -y +RUN apt clean -y +RUN rm -rf /tmp/* /var/tmp/* /var/lib/apt/lists/* + +#target +COPY target/release/ckb /bin/ckb + +#entrypoint +RUN echo "#!/bin/bash \n ckb \$@" > ./entrypoint.sh +RUN chmod +x ./entrypoint.sh + +# copy "nodes_template" to `WORKDIR`/nodes/ +COPY nodes_template/ nodes/ +RUN chown -R ckb:ckb $DATADIR/nodes + +#switch use +USER ckb + +EXPOSE 8114/tcp 8115/udp +ENTRYPOINT ["./entrypoint.sh"]