diff --git a/Tiltfile b/Tiltfile index 929bc28f..34dde9ff 100644 --- a/Tiltfile +++ b/Tiltfile @@ -38,3 +38,17 @@ docker_build( k8s_yaml("devnet/solana-devnet.yaml") k8s_resource("solana-devnet") + +# eth devnet + +# TODO: Slow - takes ~30s to rebuild on a no-op, even with caching, because npm sucks. +# We might wamt to add excludes here and use file sync for smart contract developmeent. +docker_build( + ref = "eth-node", + context = "ethereum", + dockerfile = "ethereum/Dockerfile", +) + +k8s_yaml("devnet/eth-devnet.yaml") + +k8s_resource("eth-devnet") diff --git a/devnet/eth-devnet.yaml b/devnet/eth-devnet.yaml new file mode 100644 index 00000000..4c4b13dc --- /dev/null +++ b/devnet/eth-devnet.yaml @@ -0,0 +1,56 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: eth-devnet + labels: + app: eth-devnet +spec: + ports: + - port: 8545 + name: rpc + protocol: TCP + clusterIP: None + selector: + app: eth-devnet +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: eth-devnet +spec: + selector: + matchLabels: + app: eth-devnet + serviceName: eth-devnet + replicas: 1 + template: + metadata: + labels: + app: eth-devnet + spec: + terminationGracePeriodSeconds: 1 + containers: + - name: eth-devnet + image: eth-node + command: + - npx + - ganache-cli + - --deterministic + - --time="1970-01-01T00:00:00+00:00" + - --host=0.0.0.0 + ports: + - containerPort: 8545 + name: rpc + protocol: TCP +# volumeMounts: +# - name: eth-devnet-data +# mountPath: /data +# volumeClaimTemplates: +# - metadata: +# name: eth-devnet-data +# spec: +# accessModes: [ "ReadWriteOnce" ] +# resources: +# requests: +# storage: 1Gi diff --git a/ethereum/Dockerfile b/ethereum/Dockerfile new file mode 100644 index 00000000..851715a0 --- /dev/null +++ b/ethereum/Dockerfile @@ -0,0 +1,21 @@ +# syntax=docker/dockerfile:experimental +FROM node:lts-alpine + +# Run as user, otherwise, npx explodes. +USER 1000 +RUN mkdir -p /home/node/app +RUN mkdir -p /home/node/.npm +WORKDIR /home/node/app + +ADD --chown=node:node . . + +# We want to cache node_modules *and* incorporate it into the final image. +RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \ + --mount=type=cache,uid=1000,gid=1000,target=node_modules \ + npm install && \ + cp -r node_modules node_modules_cache + +# Amusingly, Debian's coreutils version has a bug where mv believes that +# the target is on a different fs and does a full recursive copy for what +# could be a renameat syscall. Alpine does not have this bug. +RUN rmdir node_modules && mv node_modules_cache node_modules diff --git a/ethereum/package.json b/ethereum/package.json index 66cd8896..f355837b 100644 --- a/ethereum/package.json +++ b/ethereum/package.json @@ -21,6 +21,7 @@ "author": "", "license": "ISC", "dependencies": { + "ganache-cli": "^6.10.1", "truffle": "^5.1.37" } }