Skip to content

Commit

Permalink
Try to speedup dockerfile build time (#2264)
Browse files Browse the repository at this point in the history
* Try to speedup dockerfile build time

* retry

* Remove from tag

* Reorder cosmwasm steps to be before copying whole directory

* Try cache

* add -v flag to go build

* verbose flag try 2

* Try cache again

* try changing Github actions caching

* Try cache fixing

* Fix cache

* See if failure was a fluke

* Move-cache to right spot

* Try using absolute path

* Try the buildkit cache workflow

* tryfix buildkit cache

* More buildkit tries

* Check CI re-run

* See if this makes cache get found again

* Retry

* retry

* retry

* revert back to main .github folder

* Rename tests CI job

* Undo -v flag in install

* Add go mod download earlier in build process

* Try staging download better

* Accidental local change

* correct filename

* Try further layer reduction, use cache in go mod download

* See speed on cache re-run
  • Loading branch information
ValarDragon authored Aug 4, 2022
1 parent 80bd776 commit 25db335
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests & Code Coverage
name: Tests

on:
pull_request:
Expand Down Expand Up @@ -29,7 +29,7 @@ jobs:
name: Skipping test
run: echo Should I skip tests? ${{ steps.skip_check.outputs.should_skip }}

go_test:
go:
needs: should_run_go_test
if: ${{ needs.should_run_test.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
name: Run all tests
run: make test-unit

e2e_test:
e2e:
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
Expand Down
37 changes: 24 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,35 @@ ARG BASE_IMG_TAG=nonroot

FROM golang:1.18.2-alpine3.15 as build

RUN set -eux; apk add --no-cache ca-certificates build-base;
RUN apk add git
# Needed by github.com/zondax/hid
RUN apk add linux-headers
# linux-headers needed by github.com/zondax/hid
RUN set -eux; apk add --no-cache ca-certificates build-base; apk add git linux-headers

# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases
# 1) Add the releases into /lib/
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a \
https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a \
/lib/
# 2) Verify their hashes
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc; \
sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479
# Copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc`
RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a

# Get go dependencies first
COPY go.mod go.sum /osmosis/
WORKDIR /osmosis
COPY . /osmosis
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
go mod download

# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479
# Copy all files into our docker repo
COPY . /osmosis

# CosmWasm: copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc`
RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a
# build

RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/root/go/pkg/mod \
BUILD_TAGS=muslc LINK_STATICALLY=true make build

# --------------------------------------------------------
# Runner
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ build-e2e-script:
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ ./tests/e2e/initialization/$(E2E_SCRIPT_NAME)

docker-build-debug:
@docker build -t osmosis:debug --build-arg BASE_IMG_TAG=debug -f Dockerfile .
@DOCKER_BUILDKIT=1 docker build -t osmosis:debug --build-arg BASE_IMG_TAG=debug -f Dockerfile .

docker-build-e2e-init-chain:
@docker build -t osmosis-e2e-init-chain:debug --build-arg E2E_SCRIPT_NAME=chain -f tests/e2e/initialization/init.Dockerfile .
@DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-chain:debug --build-arg E2E_SCRIPT_NAME=chain -f tests/e2e/initialization/init.Dockerfile .

docker-build-e2e-init-node:
@docker build -t osmosis-e2e-init-node:debug --build-arg E2E_SCRIPT_NAME=node -f tests/e2e/initialization/init.Dockerfile .
@DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-node:debug --build-arg E2E_SCRIPT_NAME=node -f tests/e2e/initialization/init.Dockerfile .

.PHONY: test-mutation

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Conceptually, we can split the e2e setup into 2 parts:

1. Chain Initialization

The chain can either be initailized off of the current branch, or off the prior mainnet release and then upgraded to the current branch.
The chain can either be initialized off of the current branch, or off the prior mainnet release and then upgraded to the current branch.

If current, we run chain initialization off of the current Git branch
by calling `chain.Init(...)` method in the `configurer/current.go`.
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/configurer/chain/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (n *NodeConfig) Run() error {
n.t.Logf("started node container: %s", n.Name)
return true
},
5*time.Minute,
2*time.Minute,
time.Second,
"Osmosis node failed to produce blocks",
)
Expand Down

0 comments on commit 25db335

Please sign in to comment.