Skip to content
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

build: fixing building in docker container #208

Merged
merged 1 commit into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 49 additions & 48 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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 }}
13 changes: 7 additions & 6 deletions DOCKER/Dockerfile
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down Expand Up @@ -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"]

Expand Down
6 changes: 3 additions & 3 deletions DOCKER/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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\"/" \
Expand All @@ -20,4 +20,4 @@ if [ ! -d "$TMHOME/config" ]; then
mv "$TMHOME/config/genesis.json.new" "$TMHOME/config/genesis.json"
fi

exec tendermint "$@"
exec ostracon "$@"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down