Skip to content

Demo of using Docker multi-stage builds with Zeit pkg to build small node-based images

Notifications You must be signed in to change notification settings

yamalight/node-docker-pkg-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Demo of using Docker multi-stage builds with Zeit pkg to build small node-based images

This repository contains a simple demo that shows how to use Docker multi-stage builds and Zeit pkg to build small Node.js-based docker images.
The app itself is a simple Express.js server with basic "Hello world!" repsonse on root path.
Video explaining the details can be found on Youtube.

Requirements

The only requirement is Docker 17.05 or later.

Building

  1. Clone the repo
  2. Execute docker build -t docker-pkg-demo .

Running

  1. Execute docker run -it --rm -p 3000:3000 docker-pkg-demo
  2. Navigate to http://localhost:3000 in your browser

What does it do?

The build of the app is executed using new Docker multi-stage build feature.
During the first build step:

  • node:latest image is used as a base,
  • app first installs all node dependencies using yarn,
  • app is then packaged into single binary using pkg.

During the second build step:

  • alpine:latest image is used as a base,
  • libs required for node.js to work on alpine are pre-installed,
  • binary from step 1 is copied into current build and is set as command to execute

For more details see comments in Dockerfile in this repo.

License

MIT

About

Demo of using Docker multi-stage builds with Zeit pkg to build small node-based images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published