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(docker): Move to Alpine images for Dockerfile #356

Merged
merged 49 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
1c88d5f
Get rid of .env varaiables
Aug 11, 2022
300b7c3
Add default vars for docker compose down
Aug 11, 2022
0fb0ebe
Get rid of debug
Aug 11, 2022
a59052c
Create dependabot.yml
ankurdotb Aug 11, 2022
8b56ead
Deactivate test workflow
ankurdotb Aug 11, 2022
1729781
Update lint.yml
ankurdotb Aug 11, 2022
71a595e
Rename regen references
ankurdotb Aug 11, 2022
7fbe206
Update Stage 1 build
ankurdotb Aug 11, 2022
ac544a9
Remove Cosmovisor stages
ankurdotb Aug 11, 2022
3d8b33d
Remove unecessary Hadolint path
ankurdotb Aug 11, 2022
01ba259
Move Dockerfile to top-level context
ankurdotb Aug 11, 2022
1525885
Update .Dockerignore
ankurdotb Aug 11, 2022
d59055a
Change build folder
ankurdotb Aug 11, 2022
587be4d
Remove unnecessary packages from Stage 1
ankurdotb Aug 11, 2022
f732a93
Update Makefile
ankurdotb Aug 11, 2022
74c9802
Switch release dispatch guard
ankurdotb Aug 11, 2022
783a7fd
Dockerfile back in docker folder
ankurdotb Aug 11, 2022
6026861
Delete .Dockerignore
ankurdotb Aug 11, 2022
07cdb3d
Honestly, changing a filename to lowercase should be easier
ankurdotb Aug 11, 2022
e46206c
Update Dockerfile
ankurdotb Aug 11, 2022
24f7816
Update Dockerfile
ankurdotb Aug 11, 2022
c6a8c5a
Update Dockerfile
ankurdotb Aug 11, 2022
bd7c089
Update Dockerfile
ankurdotb Aug 11, 2022
8c85eca
Delete cosmovisor.sh
ankurdotb Aug 11, 2022
6432e54
Pick up Go version from go.mod
ankurdotb Aug 11, 2022
c1aa113
Moved unit tests to build job
ankurdotb Aug 11, 2022
8bdfefd
Change to Docker Buildx
ankurdotb Aug 11, 2022
975dbd8
Disable release
ankurdotb Aug 12, 2022
89a6613
Add dotenv linter
ankurdotb Aug 12, 2022
4c3c945
Update Makefile
ankurdotb Aug 12, 2022
95b8931
Reinstate user permissions
ankurdotb Aug 12, 2022
ca123c8
Update docker-compose.env
ankurdotb Aug 12, 2022
cdbbdc6
Set latest recommended version
ankurdotb Aug 12, 2022
170be85
Set Docker image version
ankurdotb Aug 12, 2022
00f6049
Update container.env
ankurdotb Aug 12, 2022
63ecd2a
Added healthcheck
ankurdotb Aug 12, 2022
72533d9
Entrypoint fix
ankurdotb Aug 12, 2022
7c3496e
Update Dockerfile
ankurdotb Aug 12, 2022
5943990
Change entrypoint copy order
ankurdotb Aug 12, 2022
3732616
Remove dockerignore for docker folder
ankurdotb Aug 12, 2022
1358406
Add protobuf generation to Docker job
ankurdotb Aug 12, 2022
6b3fd2e
Save Docker test image
ankurdotb Aug 12, 2022
b22362b
Update test.yml
ankurdotb Aug 12, 2022
04657b4
Reactivate test
ankurdotb Aug 12, 2022
1a7b184
Update Makefile
ankurdotb Aug 12, 2022
617a724
Change ldflag for name
ankurdotb Aug 12, 2022
7335ac5
Fixed incorrect folder move
ankurdotb Aug 12, 2022
02118f3
Go mod tidy
ankurdotb Aug 12, 2022
fe1d9f4
Update dispatch.yml
ankurdotb Aug 12, 2022
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
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
35 changes: 18 additions & 17 deletions .github/workflows/dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,28 @@ 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
needs: call-lint
uses: ./.github/workflows/build.yml
secrets: inherit

call-test:
name: "Test"
needs: call-build
uses: ./.github/workflows/test.yml
with:
VERSION: ${{ needs.call-build.outputs.VERSION }}
# call-test:
# name: "Test"
# needs: call-build
# uses: ./.github/workflows/test.yml
# 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
17 changes: 7 additions & 10 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,17 +190,14 @@ 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" .

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3

- name: Prepare nodes for upgrade
working-directory: ./tests/e2e-complex/upgrade
run: bash prepare.sh
Expand All @@ -227,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