-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
122 additions
and
17 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Docker | ||
|
||
on: | ||
push: | ||
# Publish `v1.2.3` tags as releases. | ||
tags: | ||
- v* | ||
|
||
env: | ||
IMAGE_NAME: node | ||
|
||
jobs: | ||
# Push image to GitHub Packages. | ||
push: | ||
runs-on: ubuntu-latest | ||
if: github.event_name == 'push' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build image | ||
run: | | ||
docker build . \ | ||
--label "org.opencontainers.image.source=${{ secrets.IMAGE_SOURCE }}" \ | ||
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \ | ||
--label "org.opencontainers.image.version=$(git describe --tags --abbrev=0)" \ | ||
--label "org.opencontainers.image.licenses=LGPL-3.0,GPL-3.0" \ | ||
-f ./Dockerfile -t "${IMAGE_NAME}" | ||
- name: Log into registry | ||
run: echo "${{ secrets.PACKAGE_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Push image | ||
run: | | ||
IMAGE_ID=ghcr.io/${{ github.repository }} | ||
# Change all uppercase to lowercase | ||
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | ||
# Strip git ref prefix from version | ||
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') | ||
# Strip "v" prefix from tag name | ||
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') | ||
# Use Docker `latest` tag convention | ||
[ "$VERSION" == "master" ] && VERSION=latest | ||
echo IMAGE_ID=$IMAGE_ID | ||
echo VERSION=$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION | ||
docker tag $IMAGE_NAME $IMAGE_ID:latest | ||
docker push $IMAGE_ID:$VERSION | ||
docker push $IMAGE_ID:latest |
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 |
---|---|---|
@@ -1,34 +1,48 @@ | ||
FROM golang:1.11-alpine AS build-env | ||
FROM golang:1.17-alpine AS build-env | ||
|
||
# Set up dependencies | ||
ENV PACKAGES make git libc-dev bash gcc linux-headers eudev-dev curl ca-certificates ssh | ||
ENV PACKAGES make git libc-dev bash gcc linux-headers eudev-dev curl ca-certificates | ||
|
||
# Set working directory for the build | ||
WORKDIR /go/src/github.com/bnb-chain/node | ||
|
||
# Add source files | ||
COPY . . | ||
|
||
# Add ssh key to download private deps | ||
COPY ~/.ssh/id_rsa /root/ssh/ | ||
|
||
# Install minimum necessary dependencies, build Cosmos SDK, remove packages | ||
RUN apk add --no-cache $PACKAGES && \ | ||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh && \ | ||
make get_vendor_deps && \ | ||
make build-alpine && \ | ||
make build && \ | ||
make install | ||
|
||
# Final image | ||
FROM alpine:edge | ||
# # Final image | ||
FROM alpine:3.16.0 | ||
|
||
# Install dependencies | ||
RUN apk add --update ca-certificates tini bash | ||
|
||
ARG USER=bnbchain | ||
ARG USER_UID=1000 | ||
ARG USER_GID=1000 | ||
|
||
# Install ca-certificates | ||
RUN apk add --update ca-certificates | ||
WORKDIR /root | ||
ENV DEFAULT_CONFIG=/configs | ||
ENV HOME=/data | ||
|
||
RUN addgroup -g ${USER_GID} ${USER} \ | ||
&& adduser -u ${USER_UID} -G ${USER} --shell /sbin/nologin --no-create-home -D ${USER} \ | ||
&& addgroup ${USER} tty | ||
RUN mkdir -p ${HOME} ${DEFAULT_CONFIG} | ||
WORKDIR ${HOME} | ||
|
||
# Copy over binaries from the build-env | ||
COPY --from=build-env /go/bin/bnbchaind /usr/bin/bnbchaind | ||
COPY --from=build-env /go/bin/bnbcli /usr/bin/bnbcli | ||
COPY docker-entrypoint.sh / | ||
COPY ./asset/ ${DEFAULT_CONFIG}/ | ||
|
||
RUN chown -R ${USER_UID}:${USER_GID} ${HOME} \ | ||
&& chmod +x /docker-entrypoint.sh | ||
|
||
USER ${USER}:${USER} | ||
|
||
# Run gaiad by default, omit entrypoint to ease using container with gaiacli | ||
CMD ["bnbchaind"] | ||
CMD ["/sbin/tini", "--", "/docker-entrypoint.sh"] |
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
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,14 @@ | ||
#!/bin/bash | ||
|
||
DEFAULT_NETWORK=("mainnet" "testnet") | ||
NETWORK=${NETWORK:-mainnet} | ||
HOME=${HOME:-/data} | ||
DEFAULT_CONFIG=${DEFAULT_CONFIG:-/configs} | ||
|
||
if echo ${DEFAULT_NETWORK[@]} | grep -q -w "${NETWORK}" | ||
then | ||
mkdir -p ${HOME}/config | ||
cp ${DEFAULT_CONFIG}/${NETWORK}/* ${HOME}/config/ | ||
fi | ||
|
||
exec "bnbchaind" "start" "--home" ${HOME} "$@" |
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,27 @@ | ||
## Docker Usage | ||
|
||
### Image | ||
```sh | ||
docker pull ghcr.io/bnb-chain/node:latest | ||
``` | ||
|
||
### Env | ||
|
||
| env | desc | default| | ||
|---|---|---| | ||
| NETWORK | default network options, if `mainnet` or `testnet` is configured, the genesis file will be automatically configured | `mainnet`| | ||
| HOME | directory for config and data | `/data` | | ||
|
||
### Example | ||
1. Start a testnet full node | ||
``` | ||
docker run -p 27146:27146 -p 27147:27147 -e NETWORK=testnet ghcr.io/bnb-chain/node:latest | ||
``` | ||
|
||
2. Start a mainnet full node with mounted volume | ||
``` | ||
docker run -p 27146:27146 -p 27147:27147 -v /tmp/chain/data:/data ghcr.io/bnb-chain/node:latest | ||
``` | ||
|
||
|
||
|