From 3d064b4ea21453b6f27405faadb958a9f47caf25 Mon Sep 17 00:00:00 2001 From: Andre Miras Date: Mon, 26 Aug 2024 22:49:00 +0200 Subject: [PATCH] ci: Fix the Dockerfile and build from CI Fix the Dockerfile and add the Docker build to the CI. The docker build error was: ``` 1.359 E: Failed to fetch http://security.debian.org/debian-security/dists/stretch/updates/main/binary-amd64/Packages 404 Not Found 1.359 E: Failed to fetch http://deb.debian.org/debian/dists/stretch/main/binary-amd64/Packages 404 Not Found 1.359 E: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/main/binary-amd64/Packages 404 Not Found 1.359 E: Some index files failed to download. They have been ignored, or old ones used instead. ``` Also use a minimal image for the final build stage. New image size is 240MB vs 4.4G for the old one. In a follow up PR we could add multi-arch build support and automatic image upload to Docker registries. --- .github/workflows/docker.yml | 13 +++++++++++++ Dockerfile | 10 ++-------- README.md | 5 +++++ 3 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..256d3d4b8 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,13 @@ +name: Docker Build +on: + pull_request: + push: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - run: docker build --tag=canto-network/canto . + - run: docker run --volume --rm canto-network/canto diff --git a/Dockerfile b/Dockerfile index 3fbf07455..2dcd0ed34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,12 @@ -FROM golang:stretch AS build-env +FROM golang:1.21 AS build-env WORKDIR /go/src/github.com/canto/canto -RUN apt-get update -y -RUN apt-get install git -y - COPY . . RUN make build -FROM golang:stretch - -RUN apt-get update -y -RUN apt-get install ca-certificates jq -y +FROM debian:12-slim WORKDIR /root diff --git a/README.md b/README.md index f2ea6d7d0..147a77a4f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Becoming A Validator +[![Build Canto Core](https://github.com/Canto-Network/Canto/actions/workflows/build.yml/badge.svg)](https://github.com/Canto-Network/Canto/actions/workflows/build.yml) +[![Docker Build](https://github.com/Canto-Network/Canto/actions/workflows/docker.yml/badge.svg)](https://github.com/Canto-Network/Canto/actions/workflows/docker.yml) +[![Sims](https://github.com/Canto-Network/Canto/actions/workflows/sims.yml/badge.svg)](https://github.com/Canto-Network/Canto/actions/workflows/sims.yml) +[![Tests / Code Coverage](https://github.com/Canto-Network/Canto/actions/workflows/test.yml/badge.svg)](https://github.com/Canto-Network/Canto/actions/workflows/test.yml) + **How to validate on the Canto Mainnet** *(canto_7700-1)*