From 13a83ffaec67d94e256b5f4e86d342f45b6d02d7 Mon Sep 17 00:00:00 2001 From: Gorka Ludlow Date: Wed, 26 Jun 2024 16:41:53 -0300 Subject: [PATCH] feat: use latest lilypad binary with every deploy (#4) * chore: add docker ignore * feat: clone lilypad source and build * feat: add local task runner --- .dockerignore | 3 +++ Dockerfile | 17 +++++++++-------- stack | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 .dockerignore create mode 100755 stack diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9343054 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +node_modules +README +.github diff --git a/Dockerfile b/Dockerfile index 95353ad..d8a54d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,15 @@ -FROM node:20.9.0 - -ARG osarch=amd64 -ARG osname=linux +# lilypad from source +FROM golang:1.22 AS build +RUN go version +RUN git clone https://github.com/Lilypad-Tech/lilypad +RUN cd lilypad && go build -v -o /usr/local/bin/lilypad -RUN curl https://api.github.com/repos/lilypad-tech/lilypad/releases/latest | grep "browser_download_url.*lilypad-$osname-$osarch" | cut -d : -f 2,3 | tr -d \" | wget -qi - -O lilypad -RUN chmod +x lilypad -RUN mv lilypad /usr/local/bin/lilypad +# node server +FROM node:20.9.0 +WORKDIR app COPY . . - RUN npm install +COPY --from=build /usr/local/bin/lilypad /usr/local/bin/lilypad CMD ["node", "./src/index.js"] diff --git a/stack b/stack new file mode 100755 index 0000000..c85e904 --- /dev/null +++ b/stack @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' + +function docker-build() { + docker build \ + -t js-cli-wrapper \ + . +} + +function docker-run() { + docker run \ + --rm \ + --name js-cli-wrapper \ + --add-host localhost:host-gateway \ + -v /tmp/lilypad/data:/tmp/lilypad/data \ + -p 3000:3000 \ + js-cli-wrapper +} + +function dev() { + npm run dev +} + +function run() { + WEB3_PRIVATE_KEY="" + + curl \ + -X POST \ + -H "Content-Type: application/json" \ + -d '{"pk": "'"${WEB3_PRIVATE_KEY}"'", "module": "cowsay:v0.0.4", "inputs": "-i Message=moo" }' \ + http://localhost:3000 +} + +function stream() { + WEB3_PRIVATE_KEY="" + + curl \ + -X POST \ + -H "Content-Type: application/json" \ + -d '{"pk": "'"${WEB3_PRIVATE_KEY}"'", "module": "cowsay:v0.0.4", "inputs": "-i Message=moo", "opts": { "stream": true } }' \ + http://localhost:3000 +} + +eval "$@"