Giter VIP home page Giter VIP logo

rudxde / lerna-dockerize Goto Github PK

View Code? Open in Web Editor NEW
34.0 34.0 0.0 3.8 MB

lerna-dockerize is a package, that generates a dockerfile for lerna projects.

Home Page: https://github.com/rudxde/lerna-dockerize

License: Apache License 2.0

JavaScript 15.65% TypeScript 83.83% Dockerfile 0.51% Shell 0.02%
build buildkit docker lerna lerna-dockerize micorservices monorepo multiple-stages npm stages

lerna-dockerize's Introduction

Hi im rudxde


๐Ÿ’ป Developer | BMW Group
๐Ÿ‘จโ€๐ŸŽ“ B. Sc. Informatics (TUM)


Check out my repositories:

lerna-dockerize's People

Contributors

dependabot[bot] avatar micharedm avatar rudxde avatar stovemeerkat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lerna-dockerize's Issues

Discontinuation of Active Maintenance for "lerna-dockerize"

Dear lerna dockerize users,

I regret to inform you that the "lerna-dockerize" GitHub repository will no longer be actively maintained. As the sole maintainer, I have made the difficult decision to step back from further development and support for this project due to time constraints.

Lerna-Dockerize has been a valuable open source resource for simplifying the Dockerization process for Lerna-based projects.

While the repository will remain publicly accessible on GitHub, i will not be actively responding to issues, reviewing pull requests, or releasing new updates. However, i encourage the community to continue using and building upon the existing codebase.

If you are passionate about this project and wish to take on the role of maintainer, please feel free to fork the repository and continue its development independently. I welcome any community-driven efforts to keep the project alive and address issues that may arise in the future.

I would like to express my heartfelt appreciation to everyone who has submitted bug reports, and provided feedback on Lerna-Dockerize. Your support has contributed to its growth and usefulness.

Thank you for your understanding and for being a part of the open source community.

Best regards,

rudx,
Former Maintainer of Lerna-Dockerize

example repo

do you have a working example repo ?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

ENOPKG `package.json` does not exist, have you run `lerna init`?

I am having this issue when using the library, does anyone knows what I am doing wrong?

Building server
[+] Building 70.8s (18/20)                                                                                                                                                                                 
 => [internal] load build definition from Dockerfile                                                                                                                                                  0.0s
 => => transferring dockerfile: 37B                                                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                                                     0.0s
 => => transferring context: 35B                                                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/amazonlinux:latest                                                                                                                                 1.1s
 => [internal] load metadata for docker.io/library/node:14                                                                                                                                            1.1s
 => [server-development  1/10] FROM docker.io/library/amazonlinux@sha256:05c170879b6dec01ee51dd380d4d63cfb9ba59e738a03531c7ab5923515af3b4                                                             0.0s
 => [base 1/4] FROM docker.io/library/node:14@sha256:ab6c8cd32006f8a4c1c795e55ddfbc7f54f5a3fb7318506ecb355cab8f5e7182                                                                                 0.0s
 => [internal] load build context                                                                                                                                                                     0.1s
 => => transferring context: 213B                                                                                                                                                                     0.0s
 => CACHED [base 2/4] COPY ./package.json ./                                                                                                                                                          0.0s
 => CACHED [base 3/4] RUN npm install                                                                                                                                                                 0.0s
 => CACHED [base 4/4] COPY ./lerna.json ./                                                                                                                                                            0.0s
 => CACHED [server-development  2/10] WORKDIR /app/apps/server                                                                                                                                        0.0s
 => CACHED [server-development  3/10] RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash # for node version 14.x                                                                               0.0s
 => CACHED [server-development  4/10] RUN yum -y install nodejs                                                                                                                                       0.0s
 => CACHED [server-development  5/10] RUN yum -y install procps                                                                                                                                       0.0s
 => CACHED [server-development  6/10] RUN yum -y install git                                                                                                                                          0.0s
 => CACHED [server-development  7/10] COPY  apps/server/package*.json ./                                                                                                                              0.0s
 => CACHED [server-development  8/10] WORKDIR /app/                                                                                                                                                   0.0s
 => ERROR [server-development  9/10] RUN npx lerna bootstrap --scope=server --includeDependencies                                                                                                    69.4s
------                                                                                                                                                                                                     
 > [server-development  9/10] RUN npx lerna bootstrap --scope=server --includeDependencies:                                                                                                                
#18 68.45 npx: installed 673 in 68.104s                                                                                                                                                                    
#18 68.61 lerna notice cli v4.0.0
#18 68.61 lerna ERR! ENOPKG `package.json` does not exist, have you run `lerna init`?
------
executor failed running [/bin/sh -c npx lerna bootstrap --

docker-compose.yml

services:
  server:
    container_name: nest_snuper
    restart: always
    env_file: .env
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - ${BACKEND_PORT}:${BACKEND_PORT}
      - 9229:9229
    command: npm run start:server

Dockerfile.base

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

./apps/server/Dockerfile

FROM amazonlinux as development

# Install npm
RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash # for node version 14.x
RUN yum -y install nodejs
RUN yum -y install procps
RUN yum -y install git

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install

lerna.json

{
    "packages": [
        "apps/**"
    ],
    "tagVersionPrefix": "v",
    "version": "2.0.0",
    "command": {
        "version": {
            "allowBranch": "main",
            "message": "chore(release): publish %s",
            "exact": true,
            "createRelease": "github",
            "conventionalCommits": true
        }
    },
    "lerna-dockerize": {
        "logLevel": "error"
    }
}

Dockerfile (generated)

FROM node:14 as base
COPY ./package.json ./
RUN npm install
COPY ./lerna.json ./
# Package server
FROM amazonlinux as server-development
WORKDIR /app/apps/server
# Install npm
RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash # for node version 14.x
RUN yum -y install nodejs
RUN yum -y install procps
RUN yum -y install git
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY  apps/server/package*.json ./
WORKDIR /app/
RUN npx lerna bootstrap --scope=server --includeDependencies
WORKDIR /app/apps/server
# final stage
FROM base
COPY --from=server-development /app/apps/server /app/apps/server

broken global argument handling with Dockerfile.base

Describe the bug
Docker has a specific way to handle globally defined ARGs (ARGs above a FROM stage). Those globally defined ARGs can be reused in several FROM blocks. E.g. if you want to use ARGs which are defined in the Dockerfile.base, you can reuse them in the package specific Dockerfiles via redefinition. But those definitions will be eleminated via lerna-dockerize.

Example Dockerfile.base

# This is the base stage, which prepares the project for further builds with lerna-dockerize.

# global arguments
ARG AWESOME_ARG=test

FROM node:12-slim
ARG AWESOME_ARG

RUN echo "varibale content: $AWESOME_ARG"
# do other stuff

To Reproduce
Steps to reproduce the behavior:

  1. add a block with a ARG definition above the FROM command in within the Dockerfile.base
  2. run npm run lerna-dockerize in you project
  3. see the compiled output --> your defined ARG does not exist in the output file

Expected behavior
The globally defined ARG should be taken into the output file.

Desktop (please complete the following information):

  • OS: Linux

Additional context
See further information about ARG handling in docker documentation: https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact

RUN command with multiple lines is not copied

Describe the bug
When using a custom dockerfile with run including multiple lines seperated by , only the first line is being added to the final dockerfile.
To Reproduce
For example using this dockerfile:


RUN  yum -y install oracle-release-el7 oracle-nodejs-release-el7 && \
     yum-config-manager --disable ol7_developer_EPEL && \
     yum -y install oracle-instantclient19.3-basiclite nodejs && \
     rm -rf /var/cache/yum

WORKDIR /myapp
ADD package.json /myapp/
ADD index.js /myapp/
RUN npm install

CMD exec node index.js

Expected behavior
Copying the entire RUN command

Screenshots
image

Desktop (please complete the following information):
Running on macos

split lerna-dockerize into several modules

the core lerna-dockerize should be an all contained bundle, which contains all commands, which each are in a self-contained package under the @lerna/dockerize scope, able to be installed separately.

The init command of #269 will be in a separate module and the core functionality of generating a docker file should be extracted into a separate module called generate.

npm install -g is omitted on generated Dockerfile

Describe the bug
on Dockerfile.base, I specified RUN npm install -g @nestjs/cli but this is line is being ignored on Dockerfile (generated)

To Reproduce
Steps to reproduce the behavior:

  1. Go to Dockerfile.base and add the line RUN npm install -g @nestjs/cli
  2. Run npm run lerna-dockerize
  3. See generated Dockerfile line RUN npm install -g @nestjs/cli is omitted

Expected behavior
It should add the line RUN npm install -g @nestjs/cli to the generated Dockerfile

Screenshots

Screen Shot 2021-11-14 at 12 30 35 AM

Desktop (please complete the following information):

  • OS: macOS Monterey Version 12.0.1

Additional context

    "lerna": "4.0.0",
    "lerna-dockerize": "^0.8.2",
    "npm": ">= 7.24.0",

Error when docker build: lerna ERR! FILTER No packages remain after filtering [ 'a' ]

I use the project from the examples: https://github.com/rudxde/lerna-dockerize/tree/master/packages/lerna-dockerize/test/integration/simple

Desktop:

  • OS: Windows 10
  • Node v.16.13.1
  • Docker v.20.10.5

To Reproduce
Running commands:

  1. npm i && lerna bootstrap
  2. npx lerna-dockerize init
  3. npm run lerna-dockerize
  4. docker build -t test .

I get an error:

Step 9/35 : RUN npx lerna bootstrap --scope=a --includeDependencies
 ---> Running in d48c7eb76185
lerna notice cli v5.1.8
lerna notice filter including "a"
lerna notice filter including dependencies
lerna info filter [ 'a' ]
lerna ERR! EFILTER No packages remain after filtering [ 'a' ]
The command '/bin/sh -c npx lerna bootstrap --scope=a --includeDependencies' returned a non-zero code: 1

The example does not contain node dependencies, but even if you add packages to dependencies, the situation will not change. Most likely I'm doing something wrong, tell me the reason for my failure.

When used with distroless or any other image not from dockerhub wrong Dockerfile generated

Describe the bug
We are using distroless image as prod base image. When used with command npx lerna-dockerize --template-dockerfile-name Dockerfile.template it generate Dockerfile with image value as FROM gcr as microservice-starter-1

To Reproduce

  1. Create file Dockerfile.template
FROM base as build
COPY ./package.json ./
RUN npm ci
RUN --if-exists npm run build
RUN rm -rf node_modules
RUN --if-exists npm ci --only=production

FROM gcr.io/distroless/nodejs as prod
WORKDIR /usr/src/app
COPY --from=build /usr/src/app/dist /usr/src/app/dist
COPY --from=build /usr/src/app/node_modules /usr/src/app/node_modules
COPY _proto /usr/_proto
ENV NODE_ENV production
# ENV GRPC_TRACE all
ENV GRPC_VERBOSITY WARNING
CMD ["dist/main.js"]

and simple base image.

  1. Run npx lerna-dockerize --template-dockerfile-name Dockerfile.template
  2. Result Dockerfile contains bad code with only gcr instead of full url
RUN npm ci --only=production
FROM gcr as microservice-starter-1
WORKDIR /app/microservices/_microservice_template

Clean install ignored in base file

Describe the bug
If I use
RUN npm ci
in the base docker file, the generated docker file for the base image contains
RUN npm install

To Reproduce
Create a base dockerfile with
FROM node:16-alpine3.15 as base
WORKDIR /app
COPY ./package.json ./
COPY ./package-lock.json ./
RUN npm ci

Expected behavior
The generated docker file looks like

FROM node:16-alpine3.15 as base
WORKDIR /app
COPY ./package.json ./
COPY ./package-lock.json ./
RUN npm ci

Additional context
This is a problem because the install is overwriting the package-lock.json in side the docker image. Dosnt seem to happen in the template docker files only when used in the base. Im using V1.0.1

add build command

An build command should be added, which generates the dockerfile and starts the docker build automatically

initialization script

To make the onboarding easier, lerna-dockerize should have an initialization script, which bootstraps a basic project setup

deprecate node 12

since the eol of node 12 will be at April 30 this year, it should be removed from the officially supported node versions of lerna-dockerize

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.