diff --git a/Dockerfile b/Dockerfile index 355273b811..3b242a7fa2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,49 +15,17 @@ RUN cd /go-ethereum && go mod download ADD . /go-ethereum # For blst -ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__" +ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__" ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__" RUN cd /go-ethereum && go run build/ci.go install -static ./cmd/geth # Pull Geth into a second stage deploy alpine container -FROM alpine:3.17 - -ARG BSC_USER=bsc -ARG BSC_USER_UID=1000 -ARG BSC_USER_GID=1000 - -ENV BSC_HOME=/bsc -ENV HOME=${BSC_HOME} -ENV DATA_DIR=/data - -ENV PACKAGES ca-certificates jq \ - bash bind-tools tini \ - grep curl sed gcc - -RUN apk add --no-cache $PACKAGES \ - && rm -rf /var/cache/apk/* \ - && addgroup -g ${BSC_USER_GID} ${BSC_USER} \ - && adduser -u ${BSC_USER_UID} -G ${BSC_USER} --shell /sbin/nologin --no-create-home -D ${BSC_USER} \ - && addgroup ${BSC_USER} tty \ - && sed -i -e "s/bin\/sh/bin\/bash/" /etc/passwd - -RUN echo "[ ! -z \"\$TERM\" -a -r /etc/motd ] && cat /etc/motd" >> /etc/bash/bashrc - -WORKDIR ${BSC_HOME} +FROM alpine:latest +RUN apk add --no-cache ca-certificates curl jq tini COPY --from=builder /go-ethereum/build/bin/geth /usr/local/bin/ -COPY docker-entrypoint.sh ./ - -RUN chmod +x docker-entrypoint.sh \ - && mkdir -p ${DATA_DIR} \ - && chown -R ${BSC_USER_UID}:${BSC_USER_GID} ${BSC_HOME} ${DATA_DIR} - -VOLUME ${DATA_DIR} - -USER ${BSC_USER_UID}:${BSC_USER_GID} - -# rpc ws graphql EXPOSE 8545 8546 8547 30303 30303/udp +ENTRYPOINT ["geth"] -ENTRYPOINT ["/sbin/tini", "--", "./docker-entrypoint.sh"] \ No newline at end of file +LABEL commit="$COMMIT" version="$VERSION" buildnum="$BUILDNUM" diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 80c5f4116c..0000000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,54 +0,0 @@ -version: '3.6' -services: - init: - image: alpine - command: - - /bin/sh - - -c - - | - chown -R 1000:1000 /data - - echo "done grany data directory permission" - volumes: - - data:/data - - bsc: - build: - context: . - dockerfile: Dockerfile - environment: - - NETWORK=mainnet - restart: unless-stopped - ports: - - 30303:30303 - - 30311:30311 - - 8545:8545 - - 8546:8546 - - 8575:8575 - - 8576:8576 - healthcheck: - test: | - [[ "$NETWORK" == "testnet" ]] && PORT=8575 || PORT=8545; - netstat -tunlp | grep $PORT > /dev/null; if [ 0 != $$? ]; then exit 1; else exit 0; fi; - - interval: 5s - retries: 5 - start_period: 10s - timeout: 3s - volumes: - - data:/data - - config:/bsc/config - -volumes: - config: - driver: local - driver_opts: - type: 'none' - o: 'bind' - device: '/tmp/bsc/config/mainnet' - data: - driver: local - driver_opts: - type: 'none' - o: 'bind' - device: '/tmp/bsc/data/mainnet' diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100644 index 7e8dda87d5..0000000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -e - -BSC_CONFIG=${BSC_HOME}/config/config.toml -BSC_GENESIS=${BSC_HOME}/config/genesis.json - -# Init genesis state if geth not exist -DATA_DIR=$(cat ${BSC_CONFIG} | grep -A1 '\[Node\]' | grep -oP '\"\K.*?(?=\")') - -GETH_DIR=${DATA_DIR}/geth -if [ ! -d "$GETH_DIR" ]; then - geth --datadir ${DATA_DIR} init ${BSC_GENESIS} -fi - -exec "geth" "--config" ${BSC_CONFIG} "$@" diff --git a/docs/docker/README.md b/docs/docker/README.md deleted file mode 100644 index 4a63dccbe6..0000000000 --- a/docs/docker/README.md +++ /dev/null @@ -1,70 +0,0 @@ -## Docker Image - -Included in this repo is a Dockerfile that you can launch BSC node for trying it out. Docker images are available on `ghcr.io/bnb-chain/bsc`. - -You can build the docker image with the following commands: -```bash -make docker -``` - -If your build machine has an ARM-based chip, like Apple silicon (M1), the image is built for `linux/arm64` by default. To build for `x86_64`, apply the --platform arg: - -```bash -docker build --platform linux/amd64 -t bnb-chain/bsc -f Dockerfile . -``` - -Before start the docker, get a copy of the config.toml & genesis.json from the release: https://github.com/bnb-chain/bsc/releases, and make necessary modification. `config.toml` & `genesis.json` should be mounted into `/bsc/config` inside the container. Assume `config.toml` & `genesis.json` are under `./config` in your current working directory, you can start your docker container with the following command: -```bash -docker run -v $(pwd)/config:/bsc/config --rm --name bsc -it bnb-chain/bsc -``` - -You can also use `ETHEREUM OPTIONS` to overwrite settings in the configuration file -```bash -docker run -v $(pwd)/config:/bsc/config --rm --name bsc -it bnb-chain/bsc --http.addr 0.0.0.0 --http.port 8545 --http.vhosts '*' --verbosity 3 -``` - -If you need to open another shell, just do: -```bash -docker exec -it bnb-chain/bsc /bin/bash -``` - -We also provide a `docker-compose` file for local testing - -To use the container in kubernetes, you can use a configmap or secret to mount the `config.toml` & `genesis.json` into the container -```bash -containers: - - name: bsc - image: bnb-chain/bsc - - ports: - - name: p2p - containerPort: 30311 - - name: rpc - containerPort: 8545 - - name: ws - containerPort: 8546 - - volumeMounts: - - name: bsc-config - mountPath: /bsc/config - - volumes: - - name: bsc-config - configMap: - name: cm-bsc-config -``` - -Your configmap `bsc-config` should look like this: -``` -apiVersion: v1 -kind: ConfigMap -metadata: - name: cm-bsc-config -data: - config.toml: | - ... - - genesis.json: | - ... - -``` \ No newline at end of file