diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f75e1b7ec..256fbdfe8 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,6 +1,6 @@ name: Build & Push # Build & Push rebuilds the ostracon docker image on every push to master and creation of tags -# and pushes the image to https://http://docker-registry.linecorp.com/link-network/v2/lbm +# and pushes the image to https://docker-registry.linecorp.com/link-network/v2/lbm on: pull_request: push: @@ -11,50 +11,51 @@ on: - "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5 jobs: -# TODO ebony: enable docker build -# build: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@master -# - name: Prepare -# id: prep -# run: | -# DOCKER_IMAGE=ostracon/ostracon -# VERSION=noop -# if [[ $GITHUB_REF == refs/tags/* ]]; then -# VERSION=${GITHUB_REF#refs/tags/} -# elif [[ $GITHUB_REF == refs/heads/* ]]; then -# VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') -# if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then -# VERSION=latest -# fi -# fi -# TAGS="${DOCKER_IMAGE}:${VERSION}" -# if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then -# TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION}" -# fi -# echo ::set-output name=tags::${TAGS} -# -# - name: Set up QEMU -# uses: docker/setup-qemu-action@master -# with: -# platforms: all -# -# - name: Set up Docker Buildx -# uses: docker/setup-buildx-action@v1 -# -# - name: Login to DockerHub -# if: ${{ github.event_name != 'pull_request' }} -# uses: docker/login-action@v1 -# with: -# username: ${{ secrets.DOCKERHUB_USERNAME }} -# password: ${{ secrets.DOCKERHUB_TOKEN }} -# -# - name: Publish to Docker Hub -# uses: docker/build-push-action@v2 -# with: -# context: . -# file: ./DOCKER/Dockerfile -# platforms: linux/amd64,linux/arm64 -# push: ${{ github.event_name != 'pull_request' }} -# tags: ${{ steps.prep.outputs.tags }} + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=ostracon/ostracon + VERSION=noop + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + elif [[ $GITHUB_REF == refs/heads/* ]]; then + VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') + if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then + VERSION=latest + fi + fi + TAGS="${DOCKER_IMAGE}:${VERSION}" + if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION}" + fi + echo ::set-output name=tags::${TAGS} + + - name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + if: ${{ github.event_name != 'pull_request' }} + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Publish to Docker Hub + uses: docker/build-push-action@v2 + with: + context: . + file: ./DOCKER/Dockerfile + platforms: linux/amd64,linux/arm64 + build-args: | + GITHUB_TOKEN=${{ secrets.TOKEN }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.prep.outputs.tags }} diff --git a/DOCKER/Dockerfile b/DOCKER/Dockerfile index cdb354522..8b6030522 100644 --- a/DOCKER/Dockerfile +++ b/DOCKER/Dockerfile @@ -1,19 +1,21 @@ -# stage 1 Generate Tendermint Binary +# stage 1 Generate Ostracon Binary FROM golang:1.15-alpine as builder +ARG GITHUB_TOKEN="" RUN apk update && \ apk upgrade && \ apk --no-cache add make git COPY / /ostracon WORKDIR /ostracon -RUN git config --global url."https://${TOKEN}:x-oauth-basic@github.com".insteadOf "https://github.com" +RUN go env -w GOPRIVATE=github.com/line/* +RUN git config --global url."https://$GITHUB_TOKEN:x-oauth-basic@github.com".insteadOf "https://github.com" RUN go mod download RUN make build-linux # stage 2 FROM golang:1.15-alpine -LABEL maintainer="hello@ostracon.com" +LABEL maintainer="ostracon@linecorp.com" -# Tendermint will be looking for the genesis file in /ostracon/config/genesis.json +# Ostracon will be looking for the genesis file in /ostracon/config/genesis.json # (unless you change `genesis_file` in config.toml). You can put your config.toml and # private validator file into /ostracon/config. # @@ -42,14 +44,13 @@ EXPOSE 26656 26657 26660 STOPSIGNAL SIGTERM COPY --from=builder /ostracon/build/ostracon /usr/bin/ostracon +COPY --from=builder /ostracon/DOCKER/docker-entrypoint.sh /usr/local/bin/ # You can overwrite these before the first run to influence # config.json and genesis.json. Additionally, you can override # CMD to add parameters to `ostracon node`. ENV PROXY_APP=kvstore MONIKER=dockernode CHAIN_ID=dockerchain -COPY ./DOCKER/docker-entrypoint.sh /usr/local/bin/ - ENTRYPOINT ["docker-entrypoint.sh"] CMD ["node"] diff --git a/DOCKER/docker-entrypoint.sh b/DOCKER/docker-entrypoint.sh index 0cb45c58a..0d705475c 100755 --- a/DOCKER/docker-entrypoint.sh +++ b/DOCKER/docker-entrypoint.sh @@ -2,8 +2,8 @@ set -e if [ ! -d "$TMHOME/config" ]; then - echo "Running tendermint init to create (default) configuration for docker run." - tendermint init + echo "Running ostracon init to create (default) configuration for docker run." + ostracon init sed -i \ -e "s/^proxy_app\s*=.*/proxy_app = \"$PROXY_APP\"/" \ @@ -20,4 +20,4 @@ if [ ! -d "$TMHOME/config" ]; then mv "$TMHOME/config/genesis.json.new" "$TMHOME/config/genesis.json" fi -exec tendermint "$@" +exec ostracon "$@" diff --git a/Makefile b/Makefile index 33273c2ee..8ca6886db 100644 --- a/Makefile +++ b/Makefile @@ -199,7 +199,7 @@ sync-docs: build-docker: build-linux cp $(OUTPUT) DOCKER/ostracon - docker build --label=ostracon --tag="ostracon/ostracon" DOCKER + docker build --build-arg GITHUB_TOKEN=$(GITHUB_TOKEN) --label=ostracon --tag="ostracon/ostracon" --file ./DOCKER/Dockerfile . rm -rf DOCKER/ostracon .PHONY: build-docker