Skip to content

Commit 25db335

Browse files
authored
Try to speedup dockerfile build time (#2264)
* 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
1 parent 80bd776 commit 25db335

File tree

5 files changed

+32
-21
lines changed

5 files changed

+32
-21
lines changed

.github/workflows/test.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Tests & Code Coverage
1+
name: Tests
22

33
on:
44
pull_request:
@@ -29,7 +29,7 @@ jobs:
2929
name: Skipping test
3030
run: echo Should I skip tests? ${{ steps.skip_check.outputs.should_skip }}
3131

32-
go_test:
32+
go:
3333
needs: should_run_go_test
3434
if: ${{ needs.should_run_test.outputs.should_skip != 'true' }}
3535
runs-on: ubuntu-latest
@@ -66,7 +66,7 @@ jobs:
6666
name: Run all tests
6767
run: make test-unit
6868

69-
e2e_test:
69+
e2e:
7070
runs-on: ubuntu-latest
7171
timeout-minutes: 25
7272
steps:

Dockerfile

+24-13
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,35 @@ ARG BASE_IMG_TAG=nonroot
88

99
FROM golang:1.18.2-alpine3.15 as build
1010

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

14+
# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases
15+
# 1) Add the releases into /lib/
16+
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a \
17+
https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a \
18+
/lib/
19+
# 2) Verify their hashes
20+
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc; \
21+
sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479
22+
# Copy the right library according to architecture. The final location will be found by the linker flag `-lwasmvm_muslc`
23+
RUN cp /lib/libwasmvm_muslc.$(uname -m).a /lib/libwasmvm_muslc.a
24+
25+
# Get go dependencies first
26+
COPY go.mod go.sum /osmosis/
1627
WORKDIR /osmosis
17-
COPY . /osmosis
28+
RUN --mount=type=cache,target=/root/.cache/go-build \
29+
--mount=type=cache,target=/root/go/pkg/mod \
30+
go mod download
1831

19-
# CosmWasm: see https://github.com/CosmWasm/wasmvm/releases
20-
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
21-
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
22-
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc
23-
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479
32+
# Copy all files into our docker repo
33+
COPY . /osmosis
2434

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

28-
RUN BUILD_TAGS=muslc LINK_STATICALLY=true make build
37+
RUN --mount=type=cache,target=/root/.cache/go-build \
38+
--mount=type=cache,target=/root/go/pkg/mod \
39+
BUILD_TAGS=muslc LINK_STATICALLY=true make build
2940

3041
# --------------------------------------------------------
3142
# Runner

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ build-e2e-script:
258258
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ ./tests/e2e/initialization/$(E2E_SCRIPT_NAME)
259259

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

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

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

269269
.PHONY: test-mutation
270270

tests/e2e/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Conceptually, we can split the e2e setup into 2 parts:
3939

4040
1. Chain Initialization
4141

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

4444
If current, we run chain initialization off of the current Git branch
4545
by calling `chain.Init(...)` method in the `configurer/current.go`.

tests/e2e/configurer/chain/node.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (n *NodeConfig) Run() error {
6868
n.t.Logf("started node container: %s", n.Name)
6969
return true
7070
},
71-
5*time.Minute,
71+
2*time.Minute,
7272
time.Second,
7373
"Osmosis node failed to produce blocks",
7474
)

0 commit comments

Comments
 (0)