-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: refactor dockerfile to add entrypoint script #993
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
28815f7
feat: refactor dockerfile to add entrypoint script
jasonyic c65f44b
fix: bsc version in makefile
jasonyic 59a316e
fix: ignore init if data exist
jasonyic 2fd4620
fix: add build arg to makefile
jasonyic 2ee4d6a
fix: lint
jasonyic fd46540
fix: lint
jasonyic 85621a9
feat: add readme for docker
jasonyic e9968f8
fix: update readme for docker
jasonyic 6f52915
fix: update readme for docker
jasonyic 5ac08f4
fix: merge conflict
jasonyic 5a47be5
feat: use release package
jasonyic 8c40eac
fix: rm unused file
jasonyic 4e82a8c
fix: update node port
jasonyic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
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 | ||
command: ["--http.addr", "0.0.0.0", "--http.port", "8545", "--http.vhosts", "*", "--verbosity", "3"] | ||
environment: | ||
- BSC_NETWORK=mainnet | ||
restart: unless-stopped | ||
ports: | ||
- 30311:30311 | ||
- 6060:6060 | ||
- 8545:8545 | ||
- 8546:8546 | ||
healthcheck: | ||
test: netstat -tunlp | grep 8545 > /dev/null; if [ 0 != $$? ]; then exit 1; else exit 0; fi; | ||
interval: 5s | ||
retries: 5 | ||
start_period: 10s | ||
timeout: 3s | ||
volumes: | ||
- data:/data | ||
|
||
volumes: | ||
data: | ||
driver: local | ||
driver_opts: | ||
type: 'none' | ||
o: 'bind' | ||
device: '/tmp/bsc/data' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
NETWORK=${BSC_NETWORK:-testnet} | ||
DATA_DIR=${BSC_DATA_DIR:-/data} | ||
BSC_CONFIG=${BSC_HOME}/config.toml | ||
|
||
# Create symlink to network config.toml & genesis.json | ||
ln -sf ./${NETWORK}/config.toml config.toml | ||
ln -sf ./${NETWORK}/genesis.json genesis.json | ||
|
||
# Default log to console | ||
sed -i '/Node\.LogConfig/,/^$/d' ./${NETWORK}/config.toml | ||
|
||
# TO-DO: remove after the default value in config.toml updated to empty | ||
# Issue: https://github.com/bnb-chain/bsc/issues/994 | ||
sed -i 's/^HTTPHost.*/HTTPHost = "0.0.0.0"/' ./${NETWORK}/config.toml | ||
|
||
# Init genesis state if geth not exist | ||
GETH_DIR=${DATA_DIR}/geth | ||
if [ ! -d "$GETH_DIR" ]; then | ||
geth --datadir ${DATA_DIR} init genesis.json | ||
fi | ||
|
||
exec "geth" "--config" ${BSC_CONFIG} "--datadir" ${DATA_DIR} "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
## 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 | ||
``` | ||
|
||
To build a specific release version, e.g. v1.1.9, with the following commands: | ||
```bash | ||
BSC_VERSION=v1.1.9 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 . | ||
``` | ||
|
||
You can start your docker container with the following command: | ||
```bash | ||
docker run --rm --name bsc -it bnb-chain/bsc | ||
``` | ||
This will start a full node in `testnet` by default. | ||
|
||
To start a full node in `mainnet`, you can pass in env variable `BSC_NETWORK`: | ||
```bash | ||
docker run --rm --name bsc -it -e BSC_NETWORK=mainnet bnb-chain/bsc | ||
``` | ||
|
||
Another env variable `BSC_DATA_DIR` is also avaiable to overwrite the default DataDir. You can also use `--datadir` to overwrite DataDir too. | ||
To overwrite default `DataDir` with env `BSC_DATA_DIR`: | ||
```bash | ||
docker run --rm --name bsc -it -e BSC_DATA_DIR=/data2 bnb-chain/bsc | ||
``` | ||
|
||
To overwrite default `DataDir` with `ETHEREUM OPTIONS` `--datadir`: | ||
```bash | ||
docker run --rm --name bsc -it bnb-chain/bsc --datadir /data2 | ||
``` | ||
`--datadir` will overrides `BSC_DATA_DIR` | ||
|
||
|
||
To start a node with geth command with `ETHEREUM OPTIONS`: | ||
```bash | ||
docker run --rm --name bsc -it -e BSC_NETWORK=mainnet 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 bsc /bin/bash | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the URL can be replaced by
.github/release.env
.the mainnet and testnet config of the new release is obtained from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
release.env
still pointing tov1.1.8
and that is why I have a ARG to build on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually every time a new version is released the additional files come from here, so it will be the same if
releas.env
doesn't updateThe reason I want you to use
release.env
is that developers will most likely forget to update the Dockerfile when they release a new versionThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when each release, no need to update the
BSC_VERSION
inDockerfile
, the build process should pass in--build-arg
for the new version to be used, similar to the new targetdocker
in makefile.Additionally, this won't cause confusion for developer between the regular release in the github repo and configuration version being used in Dockerfile.