Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 53bd95b
Author: Andrew Nikitin <andrew.nikitin@cheqd.io>
Date:   Fri Aug 12 17:22:30 2022 +0300

    build(docker): Move to Alpine images for Dockerfile (#356)

    * Get rid of .env varaiables

    * Add default vars for docker compose down

    * Get rid of debug

    * Create dependabot.yml

    * Deactivate test workflow

    * Update lint.yml

    * Rename regen references

    * Update Stage 1 build

    * Remove Cosmovisor stages

    * Remove unecessary Hadolint path

    * Move Dockerfile to top-level context

    * Update .Dockerignore

    * Change build folder

    * Remove unnecessary packages from Stage 1

    * Update Makefile

    * Switched version tag to take any version, not just `v*` prefix
    * Changed ldflags to `cheqd-node` instead of `cheqd-noded`

    * Switch release dispatch guard

    * Dockerfile back in docker folder

    * Delete .Dockerignore

    * Honestly, changing a filename to lowercase should be easier

    * Update Dockerfile

    * Update Dockerfile

    * Update Dockerfile

    * Update Dockerfile

    * Delete cosmovisor.sh

    * Pick up Go version from go.mod

    * Moved unit tests to build job

    * Change to Docker Buildx

    * Disable release

    * Add dotenv linter

    * Update Makefile

    * Reinstate user permissions

    * Update docker-compose.env

    * Set latest recommended version

    * Set Docker image version

    * Update container.env

    * Added healthcheck

    * Entrypoint fix

    * Update Dockerfile

    * Change entrypoint copy order

    * Remove dockerignore for docker folder

    * Add protobuf generation to Docker job

    * Save Docker test image

    * Update test.yml

    * Reactivate test

    * Update Makefile

    * Change ldflag for name

    * Fixed incorrect folder move

    * Go mod tidy

    * Update dispatch.yml

    Co-authored-by: Ankur Banerjee <ankurdotb@users.noreply.github.com>
  • Loading branch information
ankurdotb committed Aug 12, 2022
1 parent 9db665a commit d9218bd
Show file tree
Hide file tree
Showing 19 changed files with 184 additions and 705 deletions.
452 changes: 0 additions & 452 deletions .Dockerignore

This file was deleted.

12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Exclude all Markdown files
**/*.md

# Skip build/test folders
build-tools/
installer/
networks/
tests/

# Skip Git-related folders
.github
.git
42 changes: 42 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#################################
# GitHub Dependabot Config info #
#################################

version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

# Maintain dependencies for NPM
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"

# Maintain dependencies for Docker
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"

# Maintain dependencies for Golang
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"

# Maintain dependencies for Terraform
- package-ecosystem: "terraform"
directory: "/"
schedule:
interval: "weekly"

# Maintain dependencies for Python
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
81 changes: 37 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,6 @@ defaults:


jobs:

unit-tests:
name: "Unit Tests"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.17'

- name: Run Golang unit tests
run: go test -v ./...

build-binary:
name: "Build node binary"
Expand All @@ -38,14 +25,17 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.17'

- uses: bufbuild/buf-setup-action@v1.7.0
env:
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
go-version-file: ./go.mod

- name: Run Golang unit tests
run: go test -v ./...

# - uses: bufbuild/buf-setup-action@v1.7.0
# env:
# BUF_TOKEN: ${{ secrets.BUF_TOKEN }}

# Calls a section in Makefile > Makefile > make/proto.mk > protocgen.sh
- name: Generate golang code
- name: Generate Protobufs
run: make proto-gen

- name: Build node binary
Expand All @@ -56,49 +46,52 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: cheqd-noded
path: build-tools/cheqd-noded
path: build/cheqd-noded

- name: Set version number
id: set-version
run: |
VERSION=$(build-tools/cheqd-noded version 2>&1)
VERSION=$(build/cheqd-noded version 2>&1)
echo ::set-output name=VERSION::"$VERSION"
build-docker-images:
name: "Docker images"
build-docker:
name: "Build Docker image"
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
DOCKER_TEST_IMAGE: ${{ github.repository }}:test

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Required to fetch version

- name: Generate golang code
run: make proto-gen

- name: Build cheqd-cli Docker image 'cheqd-noded' as entrypoint
# TODO: Get rid of UID and GID
run: docker build --target base -t cheqd-cli -f docker/Dockerfile --build-arg UID="$(id -u)" --build-arg GID="$(id -g)" .
fetch-depth: 0

- name: Build cheqd-node Docker image with 'node-start' as entrypoint
run: docker build --target node -t cheqd-node -f docker/Dockerfile --build-arg UID="$(id -u)" --build-arg GID="$(id -g)" .
- uses: actions/setup-go@v3
with:
go-version-file: ./go.mod

- name: Save cheqd-cli Docker image
run: docker save -o cheqd-cli-image.tar cheqd-cli
- name: Generate Protobufs
run: make proto-gen

- name: Store cheqd-cli artifact
uses: actions/upload-artifact@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
name: cheqd-cli-image.tar
path: cheqd-cli-image.tar
install: true
version: latest

- name: Save cheqd-node Docker image
run: docker save -o cheqd-node-image.tar cheqd-node
- name: Build image
uses: docker/build-push-action@v3
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64
load: true
target: runner
tags: ${{ env.DOCKER_TEST_IMAGE }}
outputs: type=docker,dest=/tmp/cheqd-node-image.tar

- name: Store cheqd-node artifact
- name: Store Docker test image artifact
uses: actions/upload-artifact@v3
with:
name: cheqd-node-image.tar
path: cheqd-node-image.tar
path: /tmp/cheqd-node-image.tar
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.17'
go-version-file: ./go.mod

- uses: bufbuild/buf-setup-action@v1.7.0
env:
Expand Down
31 changes: 16 additions & 15 deletions .github/workflows/dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ concurrency:

jobs:

# call-lint:
# name: "Lint"
# uses: ./.github/workflows/lint.yml
call-lint:
name: "Lint"
uses: ./.github/workflows/lint.yml

# call-build:
# name: "Build"
# needs: call-lint
# uses: ./.github/workflows/build.yml
# secrets: inherit
call-build:
name: "Build"
needs: call-lint
uses: ./.github/workflows/build.yml
secrets: inherit

# call-test:
# name: "Test"
Expand All @@ -24,10 +24,11 @@ jobs:
# with:
# VERSION: ${{ needs.call-build.outputs.VERSION }}

call-release:
name: "Release"
# needs: [call-test, call-build]
if: startsWith(github.ref, 'refs/tags/v')
uses: ./.github/workflows/release.yml
with:
RELEASE_VERSION: ${{ needs.call-build.outputs.VERSION }}
# call-release:
# name: "Release"
# # needs: [call-test, call-build]
# needs: call-build
# if: ${{ github.ref_protected == true }}
# uses: ./.github/workflows/release.yml
# with:
# RELEASE_VERSION: ${{ needs.call-build.outputs.VERSION }}
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.17'
go-version-file: ./go.mod

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:

VALIDATE_BASH: true
VALIDATE_DOCKERFILE_HADOLINT: true
DOCKERFILE_HADOLINT_FILE_NAME: '../linters/.hadolint.yml'
VALIDATE_ENV: true
VALIDATE_GITHUB_ACTIONS: true
VALIDATE_JSON: true
VALIDATE_MARKDOWN: true
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: |
set -euo pipefail
bash gen-network-config.sh
CHEQD_NODE_IMAGE=cheqd-node CHEQD_NODE_VERSION=latest docker compose up -d
CHEQD_NODE_IMAGE=cheqd-node DOCKER_IMAGE_VERSION=latest docker compose up -d
- name: Check all Docker localnet nodes are active
run: |
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
working-directory: ./docker/localnet
run: |
bash gen-network-config.sh
CHEQD_NODE_IMAGE=cheqd-node CHEQD_NODE_VERSION=latest docker compose up -d
CHEQD_NODE_IMAGE=cheqd-node DOCKER_IMAGE_VERSION=latest docker compose up -d
- name: Check all Docker localnet nodes are active
run: bash tests/tools/wait-for-chain.sh
Expand Down Expand Up @@ -161,7 +161,7 @@ jobs:
working-directory: ./docker/localnet
run: |
bash gen-network-config.sh
CHEQD_NODE_IMAGE=cheqd-node CHEQD_NODE_VERSION=latest docker compose up -d
CHEQD_NODE_IMAGE=cheqd-node DOCKER_IMAGE_VERSION=latest docker compose up -d
- name: Check all Docker localnet nodes are active
run: bash ./tests/tools/wait-for-chain.sh
Expand Down Expand Up @@ -190,10 +190,10 @@ jobs:
- name: Download cheqd-cli Docker image
uses: actions/download-artifact@v3
with:
name: cheqd-cli-image.tar
name: cheqd-node-image.tar

- name: Load cheqd-cli Docker image
run: docker load -i cheqd-cli-image.tar
run: docker load -i cheqd-node-image.tar

- name: Give current user ownership
run: sudo chown "$USER":"$USER" .
Expand Down Expand Up @@ -224,10 +224,10 @@ jobs:
- name: Download cheqd-cli Docker image
uses: actions/download-artifact@v3
with:
name: cheqd-cli-image.tar
name: cheqd-node-image.tar

- name: Load cheqd-cli Docker image
run: docker load -i cheqd-cli-image.tar
run: docker load -i cheqd-node-image.tar

- name: Install cheqd-noded binary
working-directory: ./tests/e2e-complex/upgrade/cosmovisor
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

export GO111MODULE=on

BUILD_DIR ?= $(CURDIR)/build-tools
BUILD_DIR ?= $(CURDIR)/build
CHEQD_DIR := $(CURDIR)/cmd/cheqd-noded

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')

ifeq (,$(VERSION))
VERSION := $(shell echo $(shell git describe --always --tag --match "v*") | sed 's/^v//')
VERSION := $(shell git describe --exact-match 2>/dev/null)
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
Expand Down
Loading

0 comments on commit d9218bd

Please sign in to comment.