Build-image: Support code in subdirectory of repo

Created on 18 Sep 2017  路  17Comments  路  Source: netlify/build-image

I have a gatsby app - it lives in the site/ directory of my repo. When I attempt to build the app with netlify I get:

/opt/build/build.sh: line 427: gatsby: command not found

I believe this is because npm install is never successfully run - when it runs it finds no package.json in the repo root.

Is it currently possible to build a subdirectory of the repo?

Most helpful comment

There is no way to handle that in netlify.toml right now, but if you ping [email protected] with your already-configured site we can set it in the database for you. We are discussing adding it to the UI, since that is the thing we can do fastest. Coming up with a better solution for netlify.toml is still on our minds but we do not have an immediate plan about how to do so.

All 17 comments

CircleCI has an option called build_dir for this use case:

https://circleci.com/docs/1.0/configuration/#build-dir

There is a configuration option for this already in our netlify.toml file:

https://www.netlify.com/docs/continuous-deployment/#deploy-contexts

Specifically the "base" setting is a "cd here and then run my build command". As a bonus it also makes dependency caching work right ;)

@fool I have a monorepo and how can I specify configuration for multiple different sites ?

There is no way to handle that in netlify.toml right now, but if you ping [email protected] with your already-configured site we can set it in the database for you. We are discussing adding it to the UI, since that is the thing we can do fastest. Coming up with a better solution for netlify.toml is still on our minds but we do not have an immediate plan about how to do so.

@fool - any ETA on when the interface for this will be completed? If I am not on a paid plan will [email protected] help with this?

No need to be paid, @khrome83 ! Just ping us in the helpdesk.

There's no ETA for this - just some open feature requests.

@fool It would be fabulous to have the ability to deploy multiple apps in a monorepo through the deploy UI. Please keep us updated on the progress of this feature.

this is hacky but you can basically set up multiple sites separately for a monorepo: demo here https://github.com/sw-yx/TwoSitesOneRepo

@sw-yx > this is hacky but you can basically set up multiple sites separately for a monorepo: demo here https://github.com/sw-yx/TwoSitesOneRepo

What about subdirectories on the same domain? Something like
https://twositesonerepo.com/site1
https://twositesonerepo.com/site2

Any news on this? I'd love to have acces via UI.

I'm also looking for this. I'm trying to do what was suggested above but manually running npm i isn't working for some reason... 馃

Edit: Just make sure you're running npm i from the build command and not from another build system.

@sw-yx could you please show how the "multiple sites separately for a monorepo" configuration is set up in netlify UI? I've added an issue in your example repo. Thanks!

literally deploy the same repo twice...
image

and use different build commands...

image
image

if you have @wahidshafique's usecase, you can also set up a redirect from your main site to the sub site

oh, nice! and doesn't really feel "hacky", as these in fact separate sites. thanks!

Any news on this? I'd love to have access via UI.

Issue with the proposed solutions is that they'll always trigger a build for both sites, which is obviously undesirable

Edit: seems there's an official solution now 馃帀
https://www.netlify.com/blog/2019/10/09/launching-monorepo-support-for-netlify-sites/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

evanrelf picture evanrelf  路  10Comments

ehmicky picture ehmicky  路  3Comments

jwicks31 picture jwicks31  路  6Comments

MikeBeas picture MikeBeas  路  5Comments

depadiernos picture depadiernos  路  6Comments