1
0
Fork 0
mirror of https://github.com/imjasonh/node-image synced 2026-07-07 01:02:31 +00:00
No description
Find a file
2022-09-29 14:03:04 -04:00
.gitignore initial commit 2022-09-29 14:02:37 -04:00
image.sh initial commit 2022-09-29 14:03:04 -04:00
LICENSE initial commit 2022-09-29 14:03:04 -04:00
package-lock.json initial commit 2022-09-29 14:03:04 -04:00
package.json initial commit 2022-09-29 14:03:04 -04:00
README.md initial commit 2022-09-29 14:03:04 -04:00
server.js initial commit 2022-09-29 14:03:04 -04:00

Dockerless builds for npm

This demonstrates a simple Node.js app that is built into a container image and pushed to a registry without needing Docker.

Usage

Set the DOCKER_REPO env var to a Docker/OCI repository you have push access to.

export DOCKER_REPO=gcr.io/my-project/test
$ npm run image
...
gcr.io/my-project/test/node-image-test@sha256:cdef7514faa3efb8e71ad96e27da2592464e2673babdde095eb1ab68ad5ff200

You can docker run the image directly, with --silent:

$ docker run $(npm run --silent image)
...
Unable to find image 'gcr.io/my-project/test/node-image-test@sha256:cdef7514faa3efb8e71ad96e27da2592464e2673babdde095eb1ab68ad5ff200' locally
...
Status: Downloaded newer image for gcr.io/my-project/test/node-image-test@sha256:cdef7514faa3efb8e71ad96e27da2592464e2673babdde095eb1ab68ad5ff200
hello

By default the base image is node:alpine. You can select a different base image with the BASE env var, e.g., BASE=node:buster npm run image

Caveats

  • ⚠️ This runs npm install in your developer environment -- not in a container -- and malicious build scripts in dependencies can wreck your environment! Vet your dependencies.

  • This only supports linux/amd64 for now. If this becomes a real thing I image it would support multi-arch builds fairly easily. Maybe even Windows?!