js-dockerfile
v0.4.3
Published
A JavaScript API for creating Dockerfiles.
Downloads
9
Readme
js-dockerfile
js-dockerfile
is a package for creating Dockerfiles in JavaScript.
Usage
First, install js-dockerfile
using your preferred package manager:
npm install js-dockerfile
Then, import it and use it in your project like the following example:
import fs from 'node:fs'
import { Dockerfile } from 'js-dockerfile'
const d = Dockerfile.create()
const nodeVersion = 16
d.FROM(`node:${nodeVersion} AS base`)
d.RUN('apt-get update')
d.RUN('apt-get install openssl')
d.FROM('base AS dependencies')
d.RUN('npm set progress=false && npm config set depth 0')
d.RUN('npm install --omit=dev')
d.FROM('base AS release')
d.COPY('/node_modules', './node_modules', { from: 'dependencies' })
d.EXPOSE('$PRISMA_STUDIO_PORT')
d.ENTRYPOINT(["npx", "prisma", "studio"])
fs.writeFileSync('Dockerfile', d.toString())