paicku
v0.2.0
Published
A CLI for containerizing applications with buildpacks
Readme
paicku
Paicku is a wrapper of pack CLI for containerizing applications using buildpacks, in a little bit easier way which can also be called programmatically for testing locally your application.
Table of Contents
Usage
Calling via CLI
Install globally:
npm install -g paickuOr use npx (no installation required):
cd ./my-node-app-dir
npx paicku buildThe above command will output a container image to your registry with a random name.
Specify a custom image name and a path:
paicku build my-image-name --path /path/to/my/app/dirCalling it Programmatically
All the commands that Paicku supports, can be called programmatically.
Build and run an image
import {createPaicku} from 'paicku'
const paicku = createPaicku()
const result = await paicku.build({
imageName: 'my-app',
path: './app',
builder: 'docker.io/paketobuildpacks/builder-ubi8-base',
})
const container = await result.run({exposedPorts: 8080})
console.log(`Container started at ${container.getUrl()}`)
// Make a request
const response = await fetch(container.getUrl())
console.log('Response:', await response.text())
await container.stop()Available commands
Command Topics
paicku build- Build an imagepaicku builder- Display suggested builders for the given applicationpaicku help- Display help for paicku.paicku inspect- Show information about a built app imagepaicku sbom- Interact with SBoM
Examples
Build with podman
paicku build my-app --container-runtime podmanimport {createPaicku} from 'paicku'
const paicku = createPaicku()
const result = await paicku.build({
imageName: 'my-app',
'container-runtime': 'podman',
})Build with a specific builder
paicku build my-image --builder docker.io/paketobuildpacks/builder-ubi8-baseimport {createPaicku} from 'paicku'
const paicku = createPaicku()
const result = await paicku.build({
imageName: 'my-image',
builder: 'docker.io/paketobuildpacks/builder-ubi8-base',
})Build from a remote Git repository
paicku build backend-image --path https://github.com/nodeshift/mern-workshop --context-dir backendimport {createPaicku} from 'paicku'
const paicku = createPaicku()
const result = await paicku.build({
imageName: 'backend-image',
path: 'https://github.com/nodeshift/mern-workshop:backend',
})Build with environment variables
paicku build my-app --env BP_NODE_VERSION=18.*import {createPaicku} from 'paicku'
const paicku = createPaicku()
const result = await paicku.build({
imageName: 'my-app',
env: ['BP_NODE_VERSION=18.*'],
})Inspect a built image
paicku inspect my-image:latestimport {createPaicku} from 'paicku'
const paicku = createPaicku()
const result = await paicku.inspect('my-image:latest', {
output: 'json',
})
console.log('Image information:', result.parsedStdout)Get builder suggestions
paicku builder suggestimport {createPaicku} from 'paicku'
const paicku = createPaicku()
const result = await paicku.builder.suggest()
console.log('Suggested builders:', result.stdout)Download SBOM
paicku sbom download my-image:latest --output-dir ./sbomimport {createPaicku} from 'paicku'
const paicku = createPaicku()
const result = await paicku.sbom.download('my-image:latest', {
'output-dir': './sbom',
})
console.log('SBOM downloaded successfully')Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development
Install the required Node.js modules:
npm installRun CLI in Development Mode
Use the following command to run the CLI in development mode:
./bin/dev.jsOr to build an app:
./bin/dev.js build test/integration/testdata/nodejs_simple_app --container-runtime podmanRun CLI in Production Mode
To run the CLI in production mode, you need to build the application first:
npm run buildThen, execute the CLI:
./bin/run.jsNote: You must rebuild every time you make changes to the source code.
Testing
Run only the unit Tests
npm run testRun Integration Tests Only
npm run integration:test:podman
npm run integration:test:dockerRun Tests in Debug Mode
For unit tests (useful for .only or extended execution time):
npm run unit:test:debugTest Coverage
Run tests with coverage:
npm run test:report