Docker error with repo
Hello im having diffuculity of deploying my app from building the dockerfile

201 Replies
zerops:
- setup: najahniapi
run:
base: docker@26.1
prepareCommands:
- docker build -f Docker/Dockerfile.api -t najahniapi .
start: |
# Run the container (adjust port if your app listens elsewhere)
docker run --network=host najahniapi
ports:
- port: 3000
httpSupport: true
and this is the zerops file
@admin Can you help me?
runtime prepare container is different from both build container and the final container the app runs on, if you need to pass it files like Docker/Dockerfile.api, you need to add it to
build.addToRunPrepare

and the repo files will be auto imported??
as they are needed during the dockerfile build
you should pass it everything needed for the build (@Michal Saloň)
can i add . then ?
you can do just
4Z━━━━ ❌ exec # Run the container (adjust port if your app listens elsewhere)
2025-08-10T14:37:01.464Z docker run --network=host najahniapi
2025-08-10T14:37:01.464Z => 1 (exited with 1) ━━━━
run.start cannot be multiline, it has to be just a single command try just
btw none of our examples here https://docs.zerops.io/docker/overview show a
docker build example @Michal Saloň .. cc @Petrayea thats why i came here
no documentation about it
i think it doesnt work
no no
it worked

now i add envs from the ui?
https://docs.zerops.io/docker/overview#environment-variables
you need to pass down the keys you want exposed to docker
what i want is i will to do pnpm db:migrate
before building
which require the envs of db
btw is there any reason not to use zerops native nodejs service? using docker usually means you are making your life harder
my monorepo is apps/web and apps/api
where web is nextjs 15 and api is nestjs
but i want to deploy the api for now
that's essentilly the same as this https://github.com/zeropsio/recipe-nestjs
you can just have a frontend (say
app) and backend (say api) service, two Zerops Node.js services
zerops.yml supports monoreposbut i need to speciify the exact folders right?
as the api is in apps/api
doesn't matter, check this for example https://github.com/fxck/zerops-rag-starter/blob/main/zerops.yml
you are probably using nx, no?
no
turbo
but i just want to cd or use apps/api
and do everything there no need to use turborepo
yea you can do that, just do
or something like this
zerops:
- setup: api
build:
base: nodejs@20
addToRunPrepare:
- ./apps/api
buildCommands:
- npm i
- npm run build
deployFiles:
- ./dist
- node_modules
- package.json
run:
base: nodejs@20
ports:
- port: 3000
httpSupport: true
envVariables:
DATABASE_HOST: db
DATABASE_NAME: db
DATABASE_PASSWORD: ${db_password}
DATABASE_PORT: '5432'
DATABASE_USERNAME: db
STORAGE_ACCESS_KEY_ID: ${storage_accessKeyId}
STORAGE_ENDPOINT: ${storage_apiUrl}
STORAGE_REGION: us-east-1
STORAGE_S3_BUCKET_NAME: ${storage_bucketName}
STORAGE_SECRET_ACCESS_KEY: ${storage_secretAccessKey}
initCommands:
- zsc execOnce $ZEROPS_appVersionId npm run db:migrate
start: npm run start
is this correct?no need for
addToRunPrepare in this case, you build everything inside the build container.. with the way you have buildCommands set up it would run npm i on the root folder, you need to do something like this https://discord.com/channels/735781031147208777/1404107753235943524/1404115789900152833
same for deployFiles, workDir is root of your monorepo, so make sure the paths are correctly pointing to the actual dist outputahaa
alrightt
sorry for the inconvience
thnx
you can always set pipeline debug to stop before any commands are ran, then ssh into the container, try the commands yourself and only then put them in the final zerops.yml, makes for easier debugging

zerops:
- setup: api
build:
base: nodejs@20
buildCommands:
- cd apps/api
- pnpm install --frozen-lockfile
- pnpm db:migrate
- pnpm turbo run build --filter=api
deployFiles:
- apps/api/dist/
- apps/api/package.json
- apps/api/node_modules/
envVariables:
DB_HOST: ${db_hostname}
DB_PORT: '5432'
DB_USERNAME: ${db_user}
DB_PASSWORD: ${db_password}
DB_NAME: db
STORAGE_ACCESS_KEY_ID: ${storage_accessKeyId}
STORAGE_ENDPOINT: ${storage_apiUrl}
STORAGE_REGION: us-east-1
STORAGE_S3_BUCKET_NAME: ${storage_bucketName}
STORAGE_SECRET_ACCESS_KEY: ${storage_secretAccessKey}
run:
base: nodejs@20
ports:
- port: 3000
httpSupport: true
envVariables:
DB_HOST: ${db_hostname}
DB_PORT: '5432'
DB_USERNAME: ${db_user}
DB_PASSWORD: ${db_password}
DB_NAME: db
STORAGE_ACCESS_KEY_ID: ${storage_accessKeyId}
STORAGE_ENDPOINT: ${storage_apiUrl}
STORAGE_REGION: us-east-1
STORAGE_S3_BUCKET_NAME: ${storage_bucketName}
STORAGE_SECRET_ACCESS_KEY: ${storage_secretAccessKey}
start: pnpm run start
idk why this setup keep failing on pnpm db:migratewhat's the error
Zundefined
2025-08-10T15:12:52.308Z ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL Command "db:migrate" not found
2025-08-10T15:12:52.338Z
2025-08-10T15:12:52.338Z ━━━━ ❌ pnpm db:migrate ━━━━
2025-08-10T15:12:52.338Z
2025-08-10T15:12:52.338Z [BUILD ERROR] running build commands failed
and you can't do it like this, each line is a new shell instance, do when you
cd in one, it won't be applied to the next.. if you want a single shell instance, you need to do it like this https://discord.com/channels/735781031147208777/1404107753235943524/1404115789900152833
- cd apps/api && pnpm install --frozen-lockfile && pnpm turbo run db:migrate --filter=api && pnpm turbo run build --filter=api
like this?
no, literally like what is shown in the message
btw with turbo, aren't you actually suppose to run those commands from root?
how would you do this whole process if you were to do it from your local terminal? in Zerops it wil be 1:1 with that
so i dont have to cd into apps/api??
how would you build you production locally? would you first cd to api?
no hahaha
i do pnpm build which build both front and back
do exactly the same in Zerops, there is no difference between your machine and zerops container
it's just linux with current folder set to the source of your apps, so run the same commands you would locally, and then deploy the files needed to run it in production (with
deployFiles)zerops:
- setup: api
build:
base: nodejs@20
buildCommands:
- pnpm install --frozen-lockfile
- pnpm turbo run db:migrate --filter=api
- pnpm turbo run build --filter=api
deployFiles:
- apps/api/dist/**
- apps/api/package.json
- apps/api/node_modules/**
envVariables:
DB_HOST: ${db_hostname}
DB_PORT: '5432'
DB_USERNAME: ${db_user}
DB_PASSWORD: ${db_password}
DB_NAME: db
STORAGE_ACCESS_KEY_ID: ${storage_accessKeyId}
STORAGE_ENDPOINT: ${storage_apiUrl}
STORAGE_REGION: us-east-1
STORAGE_S3_BUCKET_NAME: ${storage_bucketName}
STORAGE_SECRET_ACCESS_KEY: ${storage_secretAccessKey}
run:
base: nodejs@20
ports:
- port: 3000
httpSupport: true
envVariables:
DB_HOST: ${db_hostname}
DB_PORT: '5432'
DB_USERNAME: ${db_user}
DB_PASSWORD: ${db_password}
DB_NAME: db
STORAGE_ACCESS_KEY_ID: ${storage_accessKeyId}
STORAGE_ENDPOINT: ${storage_apiUrl}
STORAGE_REGION: us-east-1
STORAGE_S3_BUCKET_NAME: ${storage_bucketName}
STORAGE_SECRET_ACCESS_KEY: ${storage_secretAccessKey}
start: pnpm --filter=api run start:prod
━━━━ 🙏 exec pnpm run start ━━━━
2025-08-10T15:19:58.426Z ERR_PNPM_NO_IMPORTER_MANIFEST_FOUND No package.json (or package.yaml, or package.json5) was found in "/var/www".
2025-08-10T15:19:58.445Z ━━━━ ❌ exec pnpm run start => 1 (exited with 1) ━━━━
in deployFiles im already taking the package.json
but the path is apps/api
how can i put them in root
when specifying the deployFiles
again, would you need to manually copy some package.json files if you did this locally?
this syntax is wrong you either put the whole path there and it will deploy as is, or mark the path with wildcard
~ from where it should deploy
i get this error even tho db is deployed and using correct env during build
it's trying to connect to db at
127.0.0.1 which is the local host of the build container, pnpm as far as I know ignores envs that do not have a certain prefix... give me a sec
or maybe turbo does
see https://turborepo.com/docs/crafting-your-repository/using-environment-variables#strict-mode
you need to run it in loose --env-mode=loose so it can see all system envsmy bad for failing builds xD
i have to get used to it
so i can write zerops.yml better
i did this but still not deploying in root
they still deployed under apps/api folder
if you want to deploy only the inside of apps/api, this is wrong
you put the wildcard the the mark from there you want to short-cut it, so
..and this assumes that inside package.json there is a
start script that can work with this structure - again, do the same you would do locally, you'd start you production from inside apps/api once its done building?
my problem now is

i have everything required
but still get modules error
as far as I know pnpm doesn't really put all dependecies in the dist folder, instead just adds symlinks to node_modules in root see - https://gist.github.com/fxck/2141a4c19160db2ca875ff417a9ab90c
i changed it like this
hopefully it work
I don't think so, as long as you are using pnpm, is doesn't install dependencies properly, as described in that gist
you need to do extra stuff to get it to produce independent production bundle
it's a nice tool for local develpment where you can share deps between different projects, but it straight up sucks for any production deployment
so i use npm?
same for turbo, both are complicated tools none really understand
npm??
and nx is better??
you can use pnpm, you just need to use the proper commands like that
deploy https://pnpm.io/cli/deploy
I personally like nx better over turbo.. but in the end it's always about your understanding of the tools you use, how to get them to do what you want to do locally, then it's to build and deploy remotelyCan i use npm for the production?
yes
I'll try to change the commands to npm
but i have to change in package.json?
as alot of things are not supported with npm
keep using pnpm then, just figure out how to do production builds
it should be just this https://pnpm.io/cli/deploy or the other options here https://gist.github.com/fxck/2141a4c19160db2ca875ff417a9ab90c
literally just run the commands locally, then copy and paste the folders and files you think you for production and try starting he production server from the new folder, then repeat the same inside
build.buildCommands and build.deployFiles
once you get it working locally it will be easyi did get it working in local
with pnpm
but when i deployed it
it says modules not found
yes, but locally your node_module in dist just uses symlinks, doesn't it?
or did you get it working fully standalone from the source code
yes node modules in dist uses symlinks
which i find symlinks are broken in file explorer in zerops
yes, because you are not deploying the target files of those symlinks, because they are saved in some global .pnpm folder, you need to get it to produce the final node_modules with all deps inside the dist, which is what this is for https://discord.com/channels/735781031147208777/1404107753235943524/1404396376577806447
Deploy a package from a workspace. During deployment, the files of the deployed package are copied to the target directory. All dependencies of the deployed package, including dependencies from the workspace, are installed inside an isolated node_modules directory at the target directory. The target directory will contain a portable package that can be copied to a server and executed without additional steps.
im getting this permission error
try with ./output, it seems like it's trying to create output folder at root perhaps
i tried with ./
same error
can you show me the error with either
./output or /build/source/output ?and with the absolute path?
/build/source/outputwdym
pnpm --filter=api deploy /build/source/output
https://gist.github.com/fxck/17127a5f22704ae2c8de748ef1408ca9same error
show me the error, is it still trying to copy to /dist/api or not?
that's strange, it clearly changes the path, this time to
/output, while before it was /dist/api, why does it ignore the full path in case of output put takes the full dist/api in account?
i did this it worked
that's because the output is now in root, while you are setting deployFiles to /build/source/ouput
if this worked try creating some
./test-output folder instead with mkdir (at relative path) and then try using ./test-ouput in the deploy command paramI have no idea why it insists to make the file in root
I guess you could just run it in root and then
mv it back to /build/source where deployFiles can pick it up
so adding
as the last command, then
this should result in
in the final runtime containeryou need to switch back to absolute paths

/ instead of ./ ... we are letting it to use root, just moving it to build folder after
i didnt do any rmdir
try sudo with that mv
same error
@Backend 🤷♂️
Why is pnpm trying to delete the directory in the first place?
Also, have you tried our built in debugging and running the commands manually inside of the build container via ssh or our web terminal? So you don't have to constantly re-trigger new deploy.
It didn't in this case https://discord.com/channels/735781031147208777/1404107753235943524/1404408344583737436
because there is
pnpm --filter=api deploy output not pnpm --filter=api deploy /outputWhat i have to change here!
.
use test-output instead of /test-output
This entire thing is weird to me:
Why is it trying to go 2 directories out of the current dir in the first place (the
../../)?
If you are in /build/source/ and try to go to ../../build/source/xxx then you would actually try to go to /xxx, which is what's probably breaking your build.
My recommendation would be to use the debug mode in the build phase set to before first command, and manually trying to run the commands to see what's actually happening:
https://docs.zerops.io/features/debug-modeIt's going from nested folder apps/api to /build/source, because it has node_modules there that it needs to get the deps from (node_modules nested in apps/api has just symlinks).. what's weird is why it's always trying to create the output folder in root, no matter what you put there
Idk either
I'll try to dig into debug mode when i have time
And see what happens
@Michal Saloň its always the permissions error
and it always tries to create files in root directory
/ instead of /build/source/? :kermitThink:Can you create a minimal reproduction on some public GitHub repo?
the zerops file?
the whole setup, turbo+pnpm
apps can be "empty"
can i do this in private? as its smth for production u know?
just so we can try ourselves
i'll do this
I am looking at your build and it's also failing at
pnpm install --frozen-lockfile
Could you try to add os: ubuntu to build and run sections of zerops.yml?
Just so we can eliminate other potential issues.
Also it seems to require python?
nah i dont have these issues lol
it doesnt fail on install
it only fail on last step of deploy
If you run on Ubuntu and have python installed, you might not see any issues like this locally.
im on windows
Scroll a bit in the Build log, you can see this:
It might be that it considers this failure to be ok, but it's still weird to me.
im on windowsAre you using WSL, or just plain Windows?
im using bash on windows
no WSL
i'll try to make a reproduction of my repo
Please do, it will let us experiemnt. By reducing the example to minimum you might even find what is causing the issue.
yea thats what im currently doing
it looks like github is so laggy now
GitHub
GitHub - LouayHouimli/ExperimentMono
Contribute to LouayHouimli/ExperimentMono development by creating an account on GitHub.
Btw, when you are done with debugging of Build pipeline on Zerops, you need to go to the build container (can use web terminal) and finish the debugging process by calling
zsc debug continue.
Otherwise it will wait 1 hour until the build pipeline times out.
oh mb didnt know that
Thats the reproduction
Still nothing??
we'll check tomorrow, people are offline already
@Louay can you send me export of your project?

without any sensitive info, I just need the structure, what services, databases etc
In the reproduction i gave
No db or storage are used
oh, ok
Its just a monorepo init which i also tried with
And same problem
I get the same error
ok, I'll check it out
well I got it working
pnpm is the biggest piece of crap I've ever seen
when running the
pnpm deploy command with sudo, it actually respects the path you choose, so it properly creates it at /build/source/api-dist
when it's done I just use chown to switch the owner of the api-dist from root back to zerops
also your
package.json in api has this for start command"start:prod": "node dist/main", but the actual main.js is in dist/src/main
so you need to change that as well
Finally lol
I'll try it and tell ya
Thanks for the help man
Will i face the same problem? When trying to add nextjs ?
the same process should work for nextjs
Alright i'll try it
i get this

even tho no runtime logs errors
is it running on the same port as defined in zerops.yml?
yea the nest start run on 3000
and in zerops its configured for 3000
yeah and in log is says it's running on port 3000?
maybe try setting host to 0.0.0.0
i wasted so many build time on errors lol
should've used the debug mode
you usually do it in express configuration
at the same place you define port

GeeksforGeeks
Express app.listen() Function - GeeksforGeeks
Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more.
lol i got the error
it was the start indention
should been below the run
is this correct??
use the debug mode, set it to "after last command", then use the web terminal to ssh into the build container


i set it into command fail
and i will check
then do
you need "after last command", because your commands succeded and it went to the next step (packing files), which is outside of the debugability
no .next
looks like it, is there something in
src?
maybe because of permissions?
cus building with sudo
nope
it's likely another stupid pnpm / turbo quirk
lol
ig as i told you
cus i can cd into it
yea but that's no the thing
pnpm deploy produces, so it's probably going to have deps problemsyou could maybe use
nah it started
ok, then just remove this
and deploy just
https://gist.github.com/fxck/6d4b008139419dbb6ba452439ca591b9
pnpm is such a piece of crap
while i always find it good for local dev
thats the first time i have to put alot of effort to make it deployed
idk why it needs this with nest and doesnt need that with next
next doesn't require node_modules at all, its build can create a
standalone bundle
so you don't have to deal with the symlink crap pnpm doesyea yea thats why
maybe i'll migrate it to npm
i dont want to deal with that in production
yea, if turbo works fine with npm, I'd suggest doing so
why its keeping using the old zerops.yml

you sure you are looking at the right pipeline?
yea

what are you using to trigger the pipeline, CLI or github?
i even deleted the service
zcli push
didn't you forget to save the changes in zerops.yml? otherwise it's impossible for it to use old zerops.yml, zcli push always archives the current code
ig my pc just lagged and didnt manage to save
i restarted vscode and it looks like using the correct one
holy moly
do you have this in your next config?
no
the reason it started in the build container was because the build container had node_modules available (it had the whole source + whatever pnpm install installed)
you need to use the
output: 'standalone' to make next produce the version that has everything includedits the same error
even with this output : standalone
i did this its running
btw i can run two services with same port?
like this
Not on the same container, but if they are different services in zerops, then yes.
im having statics not found

shouldn't the
start be just start: node .next/standalone/server.js?nah bcs im in monorepo
and there are apps/web folder
Sadly I don't work with modern front-end frameworks at all, so I can't help you much if it's some framework quirk :catSad:

is this correct?
the usage of env
If you are inside of
api service, then no, you should just use ${zeropsSubdomain}.
If you were inside of web service and wanted url from api service, then you would use ${api_zeropsSubdomain}yea im inside web service
Ok, then it's correct
@Aleš
idk why its not reading this env
even tho its defined in the gui of zerops
and i can see it with echo $NEXT_PUBLIC_API_URL in web terminal
but in the web it

it getting the web url
not the api url
doesn't it need it to be in both build and runtime?
isnt only needed on runtime?
I don't know how next works, if it prerenders some pages it might need it in build as well
i add them as plain text?
in zerops
or what ?
the problem might be elsewhere also, given it should fallback to localhost if the env wasn't defined.. you screen shows undefined
yea thats why
even tho in terminal
with echo its there
i'll try to add it in build
then the problem might be somewhere else
if it's in web terminal, the env is definitely there
yea but maybe its not seen when building?
because they are defined in ui in secrets
you need to manually add it to build.envVariables, it doesn't read them without it
but even in build it should fallback to localhost, not
undefinedin the browser its not reading it also
thats mean its reading the env but with value undefined
yes, but
undefined || 'localhost' would resolve into 'localhost'
what are you logging there? that baseUrl?I used t3 env library to read envs
Ans its working fine now
Btw you can customise the url of object storage?
no, but you should use it along https://docs.zerops.io/features/cdn#object-storage-mode
With this i can?
Aha i got it
if you enable it on your object storage service, you can use
https://storage.cdn.zerops.app/your-bucket/path/to/file and it will work automaticallyBut i meant like fully
s3.domain.com
nope, not possible at the moment
Btw i can delete the ExperimentalMono repo?
yes