Git Product home page Git Product logo

now.sh-deploy-monorepos's Introduction

Now.sh monorepo deployment support

This repository is managed with Nx. The tool allows you to easily manage monorepos and have multiple apps running in the same repo, with a shared set of libs, and a common package.json to maintain consistent versions across packages.

Video explaining the problem: https://youtu.be/7AGjUiXmkzg


The Next.JS app is in apps/frontend

To build it: yarn build frontend --> output is in dist/apps/frontend To serve it locally: yarn serve frontend

! Important: apps/frontend/pages/index.tsx depends on libs/custom-utilities (why this is important explained below)


Issue

Goal: deploy the frontend app to now.sh.

  1. We could either deploy the whole monorepo, and tell now.sh to look in dist/apps/frontend.

  2. Or cd to apps/frontend and deploy just the app.

Problems with above:

  1. We can't deploy the whole monorepo because dozens of other libraries/projects might be part of it. We only want to deploy the files necessary for the frontend app to run correctly.

  2. Because we're in a monorepo, we only have a root package.json to ensure dependency versions are in sync. We can copy the root package.json to the frontend project just before pushing it Now.sh, but we don't know which of the dependencies in are needed just for frontend (the risk of installing to many unnecessary deps)

  3. frontend might depend on some local libs/ (which it does!) We don't know which ones, so we'd have to deploy the whole libs folder - which might be very big!


Proposed solution

now.sh works incredibly well (and I apologize in advance if I get any of this wrong) if you push the sources for a Next.JS project and you allow it to:

  1. do the build
  2. configure its serverless functions to allow SSR

However, if you'd allow developers to:

  1. do the build part locally
  2. push the built artifacts to now.sh --> which then does only the second part: create serveless functions for SSR and serve it.

If we build locally, where we have all the dependencies necessary, and we deploy the built artifacts, which contains just the code needed for frontend, it would solve all the above problems.

now.sh-deploy-monorepos's People

Contributors

rarmatei avatar

Watchers

 avatar

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.