Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DISCUSSION]: deploying an NX monorepo, CI/CD and documentation. #3929

Closed
SSmale opened this issue Oct 16, 2020 · 34 comments
Closed

[DISCUSSION]: deploying an NX monorepo, CI/CD and documentation. #3929

SSmale opened this issue Oct 16, 2020 · 34 comments

Comments

@SSmale
Copy link

SSmale commented Oct 16, 2020

Description

Having a read though the documentation there seems to be a real lack of examples and best practices on how to deploy your shiny new project and searching around for articles is a sea of outdated or hacky looking workarounds.

I would like to discuss how the community is deploying their repos and some best practice input from the Dev team and then either help write some docs or at least curate them into an article. I am really enjoying developing with nx but I find the docs lacking.

A secondary thing would be some examples of CI/CD configs for the main providers for different configs.

Lastly, is there a NestJS version of these angular.json deployers

Suggested areas of documentation

preparing to deploy

  • environment files or .env for api url
  • deployment types
    • docker
    • ui from backend
    • ui and backend separately

Configuring the deployer

running your first deploy

NX CICD Pipeline by example

@MikeAliG
Copy link

Hello! Any update on this?

@SSmale
Copy link
Author

SSmale commented Oct 26, 2020

No, I was hoping for some discussion with the community. I have got mine deploying via circle ci to heroku for the nestjs api and netlify for the angular front end but it feels a little hacky.

@MikeAliG
Copy link

Thank you for your response. I tried deploying my express app to Heroku but the main issue is that we don't have a package.json for the built Node apps and that's really hard to maintain especially with Docker. Hopefully, we'll see better documentation soon since I have not yet seen a real world deployable and stable solution to tackle this issue.

@SSmale
Copy link
Author

SSmale commented Oct 28, 2020

My current approach is to send the whole NX project to Heroku and then Taylor the build and deploy npm commands to only deploy the nest backend

@MikeAliG
Copy link

I also do the same thing but it's just CI/CD commands stacked together just to deploy and this whole process feels wrong for some reason because if any update and symlinks are added to the project, this whole chain won't work anymore and we have to write another stack of CI/CD. Hopefully, we find a real solution soon because this project has increased our productivity so much and it's such a shame if we cannot deploy stuff properly.

@Delapouite
Copy link

If I'm not mistaken, a similar pain point was raised in this issue #3817

@MikeAliG
Copy link

Yes. Unfortunately that's the same issue.

@mikecann
Copy link
Contributor

mikecann commented Dec 7, 2020

I too am trying to use nx with Heroku and running into issues. So far im trying to follow this guide which basically involves building docker first then pushing to heroku: https://hackmd.io/US2eky6lSMecuHxegFZCbA?view but it doesnt seem to work for me

Just a quick edit I was able to follow a suggestion on this discussion: #1777 which mentioned using https://github.com/vercel/ncc which seems to work pretty well

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Jan 22, 2021
@Arsenalist
Copy link

Is there any example of guidance here by nrwl on how to deploy these apps?

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Mar 21, 2021
@SSmale
Copy link
Author

SSmale commented Mar 29, 2021

If we missed this issue please reply to keep it active.

a reply from a maintainer with their recommendations would be great

@github-actions github-actions bot removed the stale label Mar 29, 2021
@kasius
Copy link

kasius commented Apr 6, 2021

any update on it?

@lampewebdev
Copy link

Some best practices or some basic guidance would be nice here :)

@Arsenalist
Copy link

I ended up deploying the front-end to Netlify and the back-end to Heroku off of the same repo.

Basically, configure two different commands in package.json to build stuff. For me, the front-end command was this:

"build:ranker:prod": "node node_modules/nx/bin/nx build ranker --configuration=production --prod"

The back-end APIs were:

"serve:api:prod": "node node_modules/nx/bin/nx serve api"

Depending on where you host your FE or BE, you may have to edit your boot files (e.g., for Heroku it was Procfile) to start the app.

@vitorcamachoo
Copy link

Is there any documentation with an example how to deploy Nextjs application under NX workspace to Netlify?

@cristianPerez
Copy link

cristianPerez commented May 12, 2021

Waiting for CI/CD integration.

I had the same, question, I really love the structure of NX, and i think is a impressive tool, but I'm trying to include three different front-end projects, which I am have the deploys through circleci, directly to S3, using the feature static sites from AWS, the three front-end projects are working with similar components and look and feel, all projects are reactJS applications, but is really necessary to include the continues integration. @johnaagudelo0820

@DianaTheCoderess
Copy link

DianaTheCoderess commented Jun 3, 2021

Same problem over here ☝️I try to provision different systems via gitlab ci, and it would be awesome to have some best practice documented. All I can, I'm able to find, seems kinda hacky and unreliable. If there's someone interested, I would be happy to help and share my experiences.

@psteinroe
Copy link

Same here! I was able to setup CD to Kubernetes with Helmfile and GitHub Actions. If there is a place for it, I would be happy to share.

@SSmale
Copy link
Author

SSmale commented Jun 3, 2021

A description and a link to a gist/repo would be great!

@psteinroe
Copy link

I copy-pasted the relevant files and part of the workspace.json into a gist. Will provide a full repo when I find some time. 👍

https://gist.github.com/steinroe/4628bcf86c8ca24279b2a57663088659

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Jul 20, 2021
@SSmale
Copy link
Author

SSmale commented Jul 20, 2021 via email

@github-actions github-actions bot removed the stale label Jul 21, 2021
@egorderg
Copy link

egorderg commented Sep 1, 2021

I had the same problem and solved it with a custom repository for every app distribution/drop.
With Github Action i push the subfolder on the repos and can use heroku pipelines for CI/Review Apps and Github Actions for Lint/Test.

The problem with heroku specific files like Procfile or the engine in package.json are solved with a custom executor:
https://gist.github.com/egorderg/122a6a93d225b958bf870979d1174710
In the buildTarget you can reference your original build (i've changed it from build to build-raw).
Currently the executor copies the Procfile, overrides scripts in package.json and sets the nodeVersion in engines.

Maybe this solution helps people who are struggling with the same problems.

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Oct 17, 2021
@theoludwig
Copy link
Contributor

This issue is still relevant and should still be open.

@ghost
Copy link

ghost commented Oct 17, 2021

+1

@github-actions github-actions bot removed the stale label Oct 18, 2021
@westhechiang
Copy link

Agreed with the above. I'm having a lot of trouble running nx affected deploy with the --parallel flag enabled. For context, the deploy includes FE (sync build output with S3) and BE (build and push docker image to ECR + update ECS). In my research, I see some articles and blog posts about deploying FE apps but there seems to be quite a void for deploying with Docker and ECS.

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Dec 3, 2021
@Rafcin
Copy link

Rafcin commented Dec 4, 2021

Up

@github-actions github-actions bot removed the stale label Dec 5, 2021
@yoan-asdrubal
Copy link

yoan-asdrubal commented Dec 12, 2021

@cristianPerez

Hi CristanPerez. Do you find any solution about your scenario? i want to migrate to nx workspace but i thing I'll have the same problem you have, how to config CI CD to each of my app to diferents domains inside AWS S3.

@emmanuelbuah
Copy link

emmanuelbuah commented Jan 3, 2022

We gave up on nx alone and instead use npm workspaces + nx (buildable + publishable). External packages are installed using npm workspace for each project which ensured each projects package.json contains all external dependencies needed. This gets copied to dist folder on build as well as packaged during cd.

This is the only way I have found it to be sane. Anything else without a tailed package.json for each deployable project will bloat your deployment with a bunch of dependencies that application doesn't need.

You will find a decent amount of close tickets like this with no clear direction from the Nx team which is disappointing but its open source so ..... Even Nx's own projects have their own package.json with their dependencies. See https://github.com/nrwl/nx/tree/master/packages/tao, https://github.com/nrwl/nx/tree/master/packages/node and others.

In short, npm/yarn workspaces + Nx (buildable + publishable) will make your life easier than just Nx.

@github-actions
Copy link

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs.
If we missed this issue please reply to keep it active.
Thanks for being a part of the Nx community! 🙏

@github-actions github-actions bot added the stale label Feb 18, 2022
@vincent-thomas
Copy link

I just containerize nest applications with the "@nx-tools/nx-docker:build" executer. Then i deploy that container to aws ecs. Its works really well! This will deploy any app i want with docker. The only requirement is that it needs to have some sort of server, like express or i use nestjs. You can also use nginx, but at that point, just use netlify.

@nrwl nrwl locked and limited conversation to collaborators Mar 3, 2022
@AgentEnder AgentEnder converted this issue into discussion #9183 Mar 3, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests