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

tilt: even more multi-platform support #4186

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Dockerfile.const
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
FROM cli-gen as cli-export
FROM node:18-alpine@sha256:44aaf1ccc80eaed6572a0f2ef7d6b5a2982d54481e4255480041ac92221e2f11 as const-build
FROM node:18-alpine@sha256:6eb9c3d9bd191bd2cc6ce7ec3d5ec4c2127616140c8586af96a6bec8f28689d1 as const-build

# fetch scripts/guardian-set-init.sh deps
RUN apk update && apk add bash g++ make python3 curl jq findutils
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
FROM docker.io/golang:1.23.3-bullseye@sha256:bc1b90c2a8eb0ffb62325e02a85d51031ad3afae15b3df4b6a48b7929b00badb AS go-tools
FROM docker.io/golang:1.23.3-bullseye@sha256:9e53abacfc22cd3df3e4ebcc04ac64951b71d2a38c52b690f3807af6a2000ed2 AS go-tools

RUN mkdir /app

Expand All @@ -10,7 +10,7 @@ RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/go \
cd /app/tools && CGO_ENABLED=0 ./build.sh

# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
FROM docker.io/golang:1.23.3-bullseye@sha256:bc1b90c2a8eb0ffb62325e02a85d51031ad3afae15b3df4b6a48b7929b00badb AS go-build
FROM docker.io/golang:1.23.3-bullseye@sha256:9e53abacfc22cd3df3e4ebcc04ac64951b71d2a38c52b690f3807af6a2000ed2 AS go-build

COPY --from=go-tools /app /app

Expand All @@ -22,7 +22,7 @@ RUN --mount=type=cache,target=/root/.cache \
tools/bin/buf lint && \
tools/bin/buf generate

FROM node:16-alpine@sha256:004dbac84fed48e20f9888a23e32fa7cf83c2995e174a78d41d9a9dd1e051a20 AS node-build
FROM node:16-alpine@sha256:a1f9d027912b58a7c75be7716c97cfbc6d3099f3a97ed84aa490be9dee20e787 AS node-build

COPY --from=go-tools /app /app

Expand Down
78 changes: 27 additions & 51 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,17 @@ def k8s_yaml_with_ns(objects):

docker_build(
ref = "cli-gen",
context = ".",
dockerfile = "Dockerfile.cli",
context = "clients/js",
dockerfile = "clients/js/Dockerfile",
ignore = ["build","node_modules"],
)

docker_build(
ref = "const-gen",
context = ".",
dockerfile = "Dockerfile.const",
build_args={"num_guardians": '%s' % (num_guardians)},
build_args = {"num_guardians": '%s' % (num_guardians)},
only = ["scripts", "ethereum/.env.test"]
)

# node
Expand All @@ -142,7 +144,8 @@ docker_build(
context = ".",
dockerfile = "node/Dockerfile",
target = "build",
ignore=["./sdk/js", "./relayer"]
ignore = ["sdk/js", "sdk/js-*", "sdk/rust"],
only = ["node", "wormchain", "sdk"]
)

def command_with_dlv(argv):
Expand Down Expand Up @@ -512,26 +515,14 @@ docker_build(
context = ".",
only = ["./ethereum", "./relayer/ethereum"],
dockerfile = "./ethereum/Dockerfile",

# ignore local node_modules (in case they're present)
ignore = ["./ethereum/node_modules","./relayer/ethereum/node_modules"],
build_args = {"num_guardians": str(num_guardians), "dev": str(not ci)},

# sync external scripts for incremental development
# (everything else needs to be restarted from scratch for determinism)
#
# This relies on --update-mode=exec to work properly with a non-root user.
# https://github.com/tilt-dev/tilt/issues/3708
live_update = [
sync("./ethereum/src", "/home/node/app/src"),
],
)

if redis or generic_relayer:
docker_build(
ref = "redis",
context = ".",
only = ["./third_party"],
context = "third_party/redis",
dockerfile = "third_party/redis/Dockerfile",
)

Expand Down Expand Up @@ -573,8 +564,9 @@ if generic_relayer:
)
docker_build(
ref = "relayer-engine",
context = ".",
only = ["./relayer/generic_relayer", "./relayer/ethereum/ts-scripts/relayer/config"],
context = "relayer",
only = ["generic_relayer", "ethereum/ts-scripts/relayer/config"],
ignore = ["generic_relayer/node_modules"],
dockerfile = "relayer/generic_relayer/relayer-engine-v2/Dockerfile",
build_args = {"dev": str(not ci)}
)
Expand Down Expand Up @@ -609,31 +601,22 @@ if ci_tests:
ref = "sdk-test-image",
context = ".",
dockerfile = "testing/Dockerfile.sdk.test",
only = [],
live_update = [
sync("./sdk/js/src", "/app/sdk/js/src"),
sync("./testing", "/app/testing"),
],
only = ["ethereum", "relayer/ethereum", "solana/idl", "sdk/js", "testing"],
ignore = ["ethereum/node_modules", "relayer/ethereum/node_modules", "sdk/js/node_modules", "sdk/js/lib"],
)
docker_build(
ref = "spydk-test-image",
context = ".",
dockerfile = "testing/Dockerfile.spydk.test",
only = [],
live_update = [
sync("./spydk/js/src", "/app/spydk/js/src"),
sync("./testing", "/app/testing"),
],
only = ["spydk/js", "testing"],
ignore = ["spydk/js/node_modules", "spydk/js/lib"],
)
docker_build(
ref = "query-sdk-test-image",
context = ".",
dockerfile = "testing/Dockerfile.querysdk.test",
only = [],
live_update = [
sync("./sdk/js/src", "/app/sdk/js-query/src"),
sync("./testing", "/app/testing"),
],
only = ["sdk/js-query", "testing"],
ignore = ["sdk/js-query/node_modules", "sdk/js-query/lib"],
)

k8s_yaml_with_ns(
Expand Down Expand Up @@ -708,9 +691,10 @@ if terra2 or wormchain:
docker_build(
ref = "cosmwasm_artifacts",
context = ".",
dockerfile = "./cosmwasm/Dockerfile",
dockerfile = "cosmwasm/Dockerfile",
target = "artifacts",
platform = "linux/amd64",
only = ["cosmwasm", "sdk/rust"]
)

if terra2:
Expand Down Expand Up @@ -778,10 +762,9 @@ if sui:
docker_build(
ref = "sui-node",
target = "sui",
context = ".",
context = "sui",
dockerfile = "sui/Dockerfile",
ignore = ["./sui/sui.log*", "sui/sui.log*", "sui.log.*"],
only = ["./sui"],
ignore = ["sui.log*"],
)

k8s_resource(
Expand All @@ -797,18 +780,12 @@ if sui:
if near:
k8s_yaml_with_ns("devnet/near-devnet.yaml")

docker_build(
ref = "near-node",
context = "near",
dockerfile = "near/Dockerfile",
only = ["Dockerfile", "node_builder.sh", "start_node.sh", "README.md"],
)

docker_build(
ref = "near-deploy",
context = "near",
dockerfile = "near/Dockerfile.deploy",
ignore = ["./test"]
ignore = ["./test"],
platform="linux/amd64"
)

k8s_resource(
Expand All @@ -828,8 +805,8 @@ if wormchain:
dockerfile = "./wormchain/Dockerfile",
platform = "linux/amd64",
build_args = {"num_guardians": str(num_guardians)},
only = [],
ignore = ["./wormchain/testing", "./wormchain/ts-sdk", "./wormchain/design", "./wormchain/vue", "./wormchain/build/wormchaind"],
only = ["wormchain", "sdk"],
ignore = ["./wormchain/testing", "./wormchain/ts-sdk", "./wormchain/design", "./wormchain/vue", "./wormchain/build/wormchaind", "sdk/js", "sdk/js-*", "sdk/rust"],
)

# docker_build(
Expand Down Expand Up @@ -905,9 +882,8 @@ if wormchain:
if ibc_relayer:
docker_build(
ref = "ibc-relayer-image",
context = ".",
dockerfile = "./wormchain/ibc-relayer/Dockerfile",
only = []
context = "wormchain/ibc-relayer",
dockerfile = "wormchain/ibc-relayer/Dockerfile",
)

k8s_yaml_with_ns("devnet/ibc-relayer.yaml")
Expand Down
2 changes: 1 addition & 1 deletion aptos/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ $(TARGETS):
$(foreach dir,$(CONTRACT_DIRS), make -C $(dir) $@ &&) true

test-docker:
DOCKER_BUILDKIT=1 docker build --progress plain -f ../Dockerfile.cli -t cli-gen ..
DOCKER_BUILDKIT=1 docker build --progress plain -f ../clients/js/Dockerfile -t cli-gen ../clients/js
DOCKER_BUILDKIT=1 docker build --build-arg num_guardians=1 --progress plain -f ../Dockerfile.const -t const-gen ..
DOCKER_BUILDKIT=1 docker build --progress plain -f Dockerfile --target tests .
2 changes: 2 additions & 0 deletions clients/js/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
node_modules
8 changes: 5 additions & 3 deletions Dockerfile.cli → clients/js/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
FROM node:18-alpine@sha256:44aaf1ccc80eaed6572a0f2ef7d6b5a2982d54481e4255480041ac92221e2f11 as cli-build
FROM node:18-alpine@sha256:6eb9c3d9bd191bd2cc6ce7ec3d5ec4c2127616140c8586af96a6bec8f28689d1 as cli-build

RUN apk update && apk add g++ make python3

# Copy package.json & package-lock.json by themselves to create a cache layer
COPY clients/js/package.json clients/js/package-lock.json /clients/js/
COPY package.json package-lock.json /clients/js/

WORKDIR /clients/js

RUN npm ci

# Copy the rest of the source files, as a layer on top of the deps
COPY clients/js /clients/js
COPY . /clients/js

# Build CLI
RUN npm run build
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/Dockerfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM const-gen AS const-export
FROM cosmwasm_artifacts AS artifacts

# Contract deployment stage
FROM node:16-buster-slim@sha256:93c9fc3550f5f7d159f282027228e90e3a7f8bf38544758024f005e82607f546
FROM node:16-buster-slim@sha256:3ebf2875c188d22939c6ab080cfb1a4a6248cc86bae600ea8e2326aa03acdb8f

RUN apt update && apt install netcat curl jq -y

Expand Down
15 changes: 9 additions & 6 deletions devnet/near-devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
spec:
containers:
- name: near-node
image: near-node
image: ghcr.io/wormhole-foundation/near:2.4.0@sha256:22673c4152621a9c0624252e455b2743f20e37d8c7e3bc8e617b3e7df2ba39ce
env:
# this still results in DEBUG logs from "stats", but `warn,stats=warn` didn't work
- name: RUST_LOG
Expand All @@ -56,11 +56,14 @@ spec:
command:
- /bin/sh
- -c
- "sh /app/devnet_deploy.sh && touch success && sleep infinity"
- "npx ts-node devnet_deploy.ts && touch success && sleep infinity"
readinessProbe:
tcpSocket:
port: 3030
periodSeconds: 1
initialDelaySeconds: 15
exec:
command:
- test
- -e
- "success"
initialDelaySeconds: 5
periodSeconds: 5

restartPolicy: Always
16 changes: 4 additions & 12 deletions ethereum/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
# syntax=docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2
FROM const-gen AS const-export
FROM --platform=linux/amd64 ghcr.io/foundry-rs/foundry:nightly-55bf41564f605cae3ca4c95ac5d468b1f14447f9@sha256:8c15d322da81a6deaf827222e173f3f81c653136a3518d5eeb41250a0f2e17ea as foundry
FROM node:19.6.1-slim@sha256:a1ba21bf0c92931d02a8416f0a54daad66cb36a85d2b73af9d73b044f5f57cfc

# npm wants to clone random Git repositories - lovely.
# RUN apk add git python make build-base
# RUN apk update && apk add bash
RUN apt-get update && apt-get -y install \
git python make curl netcat vim

RUN npm i typescript -g
RUN apt-get -y install jq
FROM ghcr.io/wormholelabs-xyz/foundry:nightly-55bf41564f605cae3ca4c95ac5d468b1f14447f9@sha256:50ffe8f3ba79274eaab85ce65e769e3d66b1c680f5a9acb9c25a393c4daeeeeb as foundry
FROM node:19.6.1-slim@sha256:e684615bdfb71cb676b3d0dfcc538c416f7254697d8f9639bd87255062fd1681

COPY --from=foundry /usr/local/bin/anvil /bin/anvil
COPY --from=foundry /usr/local/bin/forge /bin/forge

RUN apt-get update && apt-get -y install git python3 build-essential curl netcat vim jq

# Run as user, otherwise, npx explodes.
USER 1000


RUN mkdir -p /home/node/app
RUN mkdir -p /home/node/.npm

Expand Down
27 changes: 21 additions & 6 deletions near/Docker.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# first build the image
# build the image and tag it appropriately

<!-- cspell:disable-next-line -->
DOCKER_BUILDKIT=1 docker build -f Dockerfile.base -t near .
<!-- cspell:disable -->

# tag the image with the appropriate version
```bash
docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile.base -t ghcr.io/wormhole-foundation/near:2.4.0 .
```

docker tag near:latest ghcr.io/wormhole-foundation/near:0.2
<!-- cspell:enable -->

# push to ghcr

docker push ghcr.io/wormhole-foundation/near:0.2
```bash
docker push ghcr.io/wormhole-foundation/near:2.4.0
```

# note: if unable to build amd64

M-series Macs may encounter an `illegal instruction` error when building the amd64 version of this image. Perform the arm64 build from a Mac and the amd64 build from another machine with native support. Then use a command like the following to create the multi-platform index from those manifests.

<!-- cspell:disable -->

```bash
docker buildx imagetools create -t ghcr.io/wormhole-foundation/near:2.4.0 ghcr.io/wormhole-foundation/near:2.4.0@sha256:<arm64-sha> ghcr.io/wormhole-foundation/near:2.4.0@sha256:<amd64-sha>
```

<!-- cspell:enable -->
1 change: 0 additions & 1 deletion near/Dockerfile

This file was deleted.

24 changes: 15 additions & 9 deletions near/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
FROM rust:1.60@sha256:48d3b5baf199dc7c378e775c47b0c40aaf7d8b23eaf67e15b095bbdaaecd1f10 AS near-node
FROM rust:1.82@sha256:d9c3c6f1264a547d84560e06ffd79ed7a799ce0bff0980b26cf10d29af888377 AS near-build

WORKDIR /tmp
WORKDIR /tmp/nearcore

RUN rustup update
RUN apt-get update && apt-get install apt-utils && apt-get install -y python3 npm curl make --no-install-recommends
RUN apt-get install -y build-essential git
# https://near-nodes.io/rpc/run-rpc-node-without-nearup#prerequisites
RUN apt-get update && apt-get install -y git binutils-dev libcurl4-openssl-dev zlib1g-dev libdw-dev libiberty-dev cmake gcc g++ python3 protobuf-compiler libssl-dev pkg-config clang llvm cargo

RUN npm i -g n
RUN n stable
RUN git init
RUN git remote add origin https://github.com/near/nearcore
# https://github.com/near/nearcore/releases/tag/2.4.0
RUN git fetch --depth 1 origin dc7b83c03529c6e9b432c649414aa9c79580df30
RUN git checkout FETCH_HEAD
RUN make sandbox-release

COPY node_builder.sh /tmp
FROM rust:1.82@sha256:d9c3c6f1264a547d84560e06ffd79ed7a799ce0bff0980b26cf10d29af888377 AS near-node

RUN ./node_builder.sh
RUN apt-get update && apt-get install -y jq python3

WORKDIR /tmp
COPY start_node.sh /tmp

RUN rm -rf /tmp/_sandbox
RUN mkdir -p /tmp/sandbox

COPY --from=near-build /tmp/nearcore/target/release/near-sandbox /tmp/nearcore/target/release/near-sandbox
RUN nearcore/target/release/near-sandbox --home /tmp/_sandbox init
2 changes: 1 addition & 1 deletion near/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/wormhole-foundation/near:0.2@sha256:c2089c5e93df2396d74f9c07e7cd3d76983fad97bddb202030ca442c2c00c3c2 AS near-contracts-build
FROM rust:1.60@sha256:48d3b5baf199dc7c378e775c47b0c40aaf7d8b23eaf67e15b095bbdaaecd1f10 AS near-contracts-build

ADD . .
RUN make clean
Expand Down
Loading
Loading