dream
dream copied to clipboard
Escape hatch for application builder [call out to node to use the JS ecosystem]
As a beginner, the ecosystem could be overwhelming. To finish the application on time, I think we can cheat a little and use an escape hatch.
With background in Javascript, my escape hatch would be Node.js
.
Here is the Dockerfile for statically compiled node.
FROM alpine
RUN apk add git python3 gcc g++ linux-headers make
RUN git clone https://github.com/nodejs/node && \
cd node && \
./configure --fully-static --enable-static && \
make
FROM scratch
COPY --from=0 /node/out/Release/node /node
CMD /node
The image is around 81MB, build time is a round 45 minutes on a 4 cores, core i5-3xxx machine.
A prebuilt image is here https://hub.docker.com/r/thangngoc89/node-static
I will find the time to properly publish this with correct node version and build matrix. In the mean time, it's good to have an escape hatch.
Usage examples:
- Start node repl:
docker run --rm -it thangngoc89/node-static:latest /node
- Copy node as part of your docker build
# Dockerfile
FROM debian
COPY --from=thangngoc89/node-static /node /node
Now you application can call /node
and execute code
I understood this issue only on the last line of the comment :) It's about having node
ready for a native app to call into, so you can use various JS ecosystem libraries.
@thangngoc89 what do you think should be done with this knowledge? Create an example? Add just a note somewhere? Leave this in an issue so people can search the repo for it?
@aantron I think creating an example would be nice. I created the solution because I can’t figure out how to deal with utf-8 libraries for making slug from string. But now I do know how to do it in OCaml 😂.