1.0.9 • Published 11 months ago

lerna-dockerize v1.0.9

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
11 months ago

lerna-dockerize

lerna-dockerize is a package, that generates a dockerfile for lerna (see github/lerna for more information about lerna) projects.

It generates an multistage build Dockerfile, with stages for each package.

install

npm i --save-dev lerna-dockerize

project setup

You will need at least two dockerfiles.

Base Dockerfile

The base dockerfile should contain lerna and the lerna configuration. It will be build first and should be used in every other dockerfile as source in the FROM clause. In this dockerfile you should copy every file which you need from you root project.

Create the file Dockerfile.base in your projects root and add the following content:

FROM node:14 as base
COPY ./package.json ./
RUN npm i
COPY ./lerna.json ./

In the end an Dockerstage will be created based on the last Base Dockerfile stage containg ever package

Custom package Dockerfile

You can create an custom Dockerfile for each package. If a package has no Dockerfile lerna-dockerize will try to use the template Dockerfile. The Dockerfile's working directory will be set inside the package directory. You don't need to perform lerna bootstrap on your own. just add the line RUN npm install and lerna dockerize will handle the bootstrapping.

Multiple stages

You can use multiple stages in each stage an RUN npm install step will be replaced by bootstrapping and adding the dependent packages. The last stage of the dockerfile will be used for the install into other packages. The names of the stages will be scoped with the package name as a prefix.

Template Dockerfile

The template Dockerfile will be used inside of each package, which doesn't provide its own dockerfile. The template Dockerfile will behave like an custom package Dockerfile.

Create the file Dockerfile.template with your required steps for your packages:

FROM base as build

COPY ./package.json ./

RUN npm install

RUN --if-exists npm run build

generate dockerfile

add a npm script to your package.json:

{
    "scripts": {
        "lerna-dockerize": "lerna-dockerize",
    }
}

and run it:

npm run lerna-dockerize

This will output an Dockerfile in your projects root.

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.4

2 years ago

1.0.3

2 years ago

0.9.4

2 years ago

0.9.5

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.9.3

2 years ago

0.9.0

2 years ago

0.9.2

2 years ago

0.9.1

2 years ago

0.8.4

2 years ago

0.8.3

2 years ago

0.8.2

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago