部署详情
1、编写Dockerfile镜像
beacon chain对应Dockerfile文件
# 使用 Ubuntu 20.04 作为基础镜像
FROM ubuntu:20.04# 安装必要的系统库和工具
RUN apt-get update && \apt-get install -y curl && \apt-get clean# 创建存储数据的目录
RUN mkdir -p /data/prysm
WORKDIR /data/prysm# 下载 Prysm beacon chain 二进制文件并将其复制到 /usr/local/bin/beacon-chain
RUN curl -Lo /usr/local/bin/beacon-chain https://github.com/prysmaticlabs/prysm/releases/download/v5.0.3/beacon-chain-v5.0.3-linux-amd64 && \chmod +x /usr/local/bin/beacon-chain && \ls -l /usr/local/bin/beacon-chainCOPY beacon-start.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/beacon-start.sh# 生成授权密钥并运行 Prysm Beacon Chain
#CMD /bin/sh -c "/usr/local/bin/beacon-chain generate-auth-secret && /usr/local/bin/beacon-chain --accept-terms-of-use --execution-endpoint=http://eth:8551 --jwt-secret=/data/prysm/jwt.hex --checkpoint-sync-url=https://beaconstate.info --genesis-beacon-api-url=https://beaconstate.info --datadir /data/beacondata"
# 设定容器启动时运行的命令
ENTRYPOINT ["/usr/local/bin/beacon-start.sh"]
ethereum对应Dockerfile文件
# 使用 Ubuntu 20.04 作为基础镜像
FROM ubuntu:20.04# 安装必要的系统库和工具
RUN apt-get update && \apt-get install -y curl && \apt-get clean# 创建存储数据的目录
RUN mkdir -p /data/ethdata
WORKDIR /data/ethdata# 下载 eth 二进制文件并将其解压到 /usr/local/bin/geth
RUN curl -Lo /tmp/geth.tar.gz https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.14.0-87246f3c.tar.gz && \tar -xzf /tmp/geth.tar.gz -C /tmp/ && \mv /tmp/geth-linux-amd64-1.14.0-87246f3c/geth /usr/local/bin/ && \chmod +x /usr/local/bin/geth && \rm /tmp/geth.tar.gz# 设定容器启动时运行的命令
ENTRYPOINT ["/usr/local/bin/geth"]
2、beacon chain 对应执行脚本beacon-start.sh文件
# cat beacon-start.sh
#!/bin/bash/usr/local/bin/beacon-chain generate-auth-secret/usr/local/bin/beacon-chain \--accept-terms-of-use \--execution-endpoint=http://eth:8545 \--jwt-secret=/data/prysm/jwt.hex \--checkpoint-sync-url=https://beaconstate.info \--genesis-beacon-api-url=https://beaconstate.info \--datadir /data/beacondata
3、手动打镜像,存储镜像
beacon chain镜像
/data/docker-compose/eth# docker build -t beacon-chain:v5.0.3 .
[+] Building 1.6s (12/12) FINISHED docker:default=> [internal] load build definition from Dockerfile 0.0s=> => transferring dockerfile: 1.13kB 0.0s=> [internal] load metadata for docker.io/library/ubuntu:20.04 1.5s=> [internal] load .dockerignore 0.0s=> => transferring context: 2B 0.0s=> [1/7] FROM docker.io/library/ubuntu:20.04@sha256:874aca52f79ae5f8258faff03e10ce99ae836f6e7d2df6ecd3da5c1cad3a912b 0.0s=> [internal] load build context 0.0s=> => transferring context: 388B 0.0s=> CACHED [2/7] RUN apt-get update && apt-get install -y curl && apt-get clean 0.0s=> CACHED [3/7] RUN mkdir -p /data/prysm 0.0s=> CACHED [4/7] WORKDIR /data/prysm 0.0s=> CACHED [5/7] RUN curl -Lo /usr/local/bin/beacon-chain https://github.com/prysmaticlabs/prysm/releases/download/v5.0.3/beacon-chain-v5.0.3-linux-amd64 && chmod +x /usr/local/bin/beacon-chain && ls -l /usr/local/bin/beaco 0.0s=> CACHED [6/7] COPY beacon-start.sh /usr/local/bin/ 0.0s=> CACHED [7/7] RUN chmod +x /usr/local/bin/beacon-start.sh 0.0s=> exporting to image 0.0s=> => exporting layers 0.0s=> => writing image sha256:55bbc4ebf584ed73c90d2e57dc5eaff32f3152f238e6c566af48fcc14463797d 0.0s=> => naming to docker.io/library/beacon-chain:v5.0.3
eth镜像
/data/docker-compose/eth# docker build -t beacon-ethereum:v1.14.0 .
[+] Building 0.9s (9/9) FINISHED docker:default=> [internal] load build definition from Dockerfile 0.0s=> => transferring dockerfile: 732B 0.0s=> [internal] load metadata for docker.io/library/ubuntu:20.04 0.8s=> [internal] load .dockerignore 0.0s=> => transferring context: 2B 0.0s=> [1/5] FROM docker.io/library/ubuntu:20.04@sha256:874aca52f79ae5f8258faff03e10ce99ae836f6e7d2df6ecd3da5c1cad3a912b 0.0s=> CACHED [2/5] RUN apt-get update && apt-get install -y curl && apt-get clean 0.0s=> CACHED [3/5] RUN mkdir -p /data/ethdata 0.0s=> CACHED [4/5] WORKDIR /data/ethdata 0.0s=> CACHED [5/5] RUN curl -Lo /tmp/geth.tar.gz https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.14.0-87246f3c.tar.gz && tar -xzf /tmp/geth.tar.gz -C /tmp/ && mv /tmp/geth-linux-amd64-1.14.0-87246f3c/geth /u 0.0s=> exporting to image 0.0s=> => exporting layers 0.0s=> => writing image sha256:7394054b8bf27cd984b3d9e9930be2594d8df2afa16b2ca6eabe70735bf9d717 0.0s=> => naming to docker.io/library/beacon-ethereum:v1.14.0
推送镜像
#登录镜像仓库
/data/docker-compose/eth# docker login docker.io
Log in with your Docker ID or email address to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com/ to create one.
You can log in with your password or a Personal Access Token (PAT). Using a limited-scope PAT grants better security and is required for organizations using SSO. Learn more at https://docs.docker.com/go/access-tokens/Username: devocenter
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded
# 查询打好的镜像
root@iZt4ndiwb4prb26wx84bsuZ:/data/docker-compose/eth# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
beacon-chain v5.0.3 55bbc4ebf584 About an hour ago 219MB
beacon-ethereum v1.14.0 7394054b8bf2 2 hours ago 202MB
# 镜像打tag
root@iZt4ndiwb4prb26wx84bsuZ:/data/docker-compose/eth# docker tag 7394054b8bf2 devocenter/beacon-ethereum
root@iZt4ndiwb4prb26wx84bsuZ:/data/docker-compose/eth# docker tag 7394054b8bf2 devocenter/beacon-ethereum:v1.14.0
root@iZt4ndiwb4prb26wx84bsuZ:/data/docker-compose/eth# docker tag 55bbc4ebf584 devocenter/beacon-chain
root@iZt4ndiwb4prb26wx84bsuZ:/data/docker-compose/eth# docker tag 55bbc4ebf584 devocenter/beacon-chain:v5.0.3
root@iZt4ndiwb4prb26wx84bsuZ:/data/docker-compose/eth# docker push devocenter/beacon-ethereum:v1.14.0
The push refers to repository [docker.io/devocenter/beacon-ethereum]
a152e957080c: Pushed
5f70bf18a086: Pushed
1d5e5fbbe9db: Pushed
5e37725372fe: Pushed
4a1518ebc26e: Mounted from library/ubuntu
v1.14.0: digest: sha256:659c50b4bba6b08354ad4166b0b471744b4f9be97a416ae8f904adbd2512e2c6 size: 1366
root@iZt4ndiwb4prb26wx84bsuZ:/data/docker-compose/eth# docker push devocenter/beacon-ethereum
Using default tag: latest
The push refers to repository [docker.io/devocenter/beacon-ethereum]
a152e957080c: Layer already exists
5f70bf18a086: Layer already exists
1d5e5fbbe9db: Layer already exists
5e37725372fe: Layer already exists
4a1518ebc26e: Layer already exists
latest: digest: sha256:659c50b4bba6b08354ad4166b0b471744b4f9be97a416ae8f904adbd2512e2c6 size: 1366
root@iZt4ndiwb4prb26wx84bsuZ:/data/docker-compose/eth# docker push devocenter/beacon-chain:v5.0.3
The push refers to repository [docker.io/devocenter/beacon-chain]
52ca92dcfa3a: Pushed
1fd23617e726: Pushed
a421a50af66c: Pushed
5f70bf18a086: Mounted from devocenter/beacon-ethereum
719f3a1de368: Pushed
5e37725372fe: Mounted from devocenter/beacon-ethereum
4a1518ebc26e: Mounted from devocenter/beacon-ethereum
v5.0.3: digest: sha256:eaceaa75d9eb9ae14290bc954729f58ccaa859de7119f4fd66fed2945c82b7b3 size: 1780
root@iZt4ndiwb4prb26wx84bsuZ:/data/docker-compose/eth# docker push devocenter/beacon-chain
Using default tag: latest
The push refers to repository [docker.io/devocenter/beacon-chain]
52ca92dcfa3a: Layer already exists
1fd23617e726: Layer already exists
a421a50af66c: Layer already exists
5f70bf18a086: Layer already exists
719f3a1de368: Layer already exists
5e37725372fe: Layer already exists
4a1518ebc26e: Layer already exists
latest: digest: sha256:eaceaa75d9eb9ae14290bc954729f58ccaa859de7119f4fd66fed2945c82b7b3 size: 1780
镜像仓库查看镜像