Skip to content

Commit

Permalink
feat: use latest lilypad binary with every deploy (#4)
Browse files Browse the repository at this point in the history
* chore: add docker ignore

* feat: clone lilypad source and build

* feat: add local task runner
  • Loading branch information
AquiGorka authored Jun 26, 2024
1 parent 097ed75 commit 13a83ff
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
README
.github
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
45 changes: 45 additions & 0 deletions stack
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit 13a83ff

Please sign in to comment.