Not able to create docker image of keystonejs because it contains lot of package.json and packages inside it

1k Views Asked by At

I am trying to create docker image of this official public repo of keystonejs https://github.com/keystonejs/keystone

But it contains lot of packages inside it and each package contains package.json inside it, it is some short of multi-module project.

the package.json is present in root directory as well as in sub directory.

how can we create docker image containing all these packages ? if anyone has worked on keystonejs please help me on this ?

thank you

1

There are 1 best solutions below

0
On

The Keystone codebase is indeed "some sort of multi-module project" – it's what's called a monorepo.

Generally, the term "monorepo" refers to a collection of source code from different projects, stored together in a single repository, inside a version control system (like git for example). They're fairly common for large projects:

Google, Facebook, Microsoft, Uber, Airbnb, and Twitter all employ very large monorepos with varying strategies to scale build systems and version control software with a large volume of code and daily changes. — Wikipedia: Monorepos

In the NodeJS ecosystem "monorepo" often refers to a repo that includes code for multiple npm packages.

In Keystone case, the main repo includes several npm packages (in the packages dir), a bunch of tests, the Keystone marketing and docs websites (in docs), and various other bits and pieces.

Thinkmill, the team that builds Keystone, has a guide on the monorepo patterns and tools they use. A Google search will give you plenty of other takes; it's a popular topic.

How can we create docker image containing all these packages?

If you want to deploy a Keystone app using docker you don't need to mess with the Keystone repo itself. You just want to install Keystone as a dependency, like any other npm package. The steps are basically:

  1. Create a project in your own repo
  2. Pull the core Keystone npm package (@keystone-6/core) in as a dependancy, then..
  3. Add a dockerfile that builds and runs the app

Getting a Keystone project running is actually super easy – it only take a few files. There's even a tool called create-keystone-app that sets them up for you. I'd suggest running thought the Getting Started guide to get a simple app running locally, then write your dockerfile there.