Netlify Docker Local Build Image Base Directory

I’m trying to get the netlify docker build-image set up locally, however I can’t seem to set the base directory. I can’t simply change the build command or netlify toml in the root of the repository as the repo contains two projects that get built out separately. web (for the website) and studio (for Sanity studio). There’s a ./web/netlify.toml and a ./studio/netlify.toml in place.

When I run the command /opt/build-bin/build npm run build it ends up trying to build the root directory, which fails.

Also, when the docker image is started using does this use the currently checked out branch, or the main branch?

Hey there, @nick.taylor :wave:

Welcome to the Netlify Forums! Can you please share the full error message you are encountering, as well as a link to the site and/or site name you are trying to set up? This will help us look into your obstacles further.

Thanks so much

Hi @hillary,

Thanks for your reply, I’ve managed to resolve this myself to get to the point where I can test all the build functionality is working as expected.

I had to do the following
ENV_VARS=here /opt/build-bin/build "cd ./web && npm install && npm build" (dropping the ‘;’ from between the env vars and the /opt/build-bin/build... and then change directory, install and build the subfolder, which had to be in quotes.

That got the correct folder built.

The answer to my question about the branch that it used, it uses the branch that is currently checked out within the repository that you pass over when running


1 Like

Hey there, @nick.taylor :wave:

Thanks so much for coming back and sharing this solution with the Forums! This will benefit future members who encounter something similar. Happy building :rocket: