Monorepo with 2 Apps cli push specific app

If I have a nx monorepo where I will have multiple analog.js apps Is there a way to choose which app should be pushed by the zcli. maybe through providing another yml file?
3 Replies
Jan Saidl
Jan Saidl2mo ago
Hi, you can still have one zerops.yaml. In which there can be more setup sections. By default, the setup with the same name as the target service is used. You can specify which setup you want to use using the --setup flag zcli push --setup SETUP
zerops:
- setup: app1
build:
base: go@latest
buildCommands:
- echo "build app 1"
deployFiles: main

run:
base: alpine@latest
start: ./main --port 8080

- setup: app2
build:
base: go@latest
buildCommands:
- echo "build app 2"
deployFiles: main

run:
base: alpine@latest
start: ./main --port 8080
zerops:
- setup: app1
build:
base: go@latest
buildCommands:
- echo "build app 1"
deployFiles: main

run:
base: alpine@latest
start: ./main --port 8080

- setup: app2
build:
base: go@latest
buildCommands:
- echo "build app 2"
deployFiles: main

run:
base: alpine@latest
start: ./main --port 8080
zcli push --setup app1 zcli push --setup app2
Aleš
Aleš2mo ago
@elite-benni which app should be pushed is decided by the param you pass to the push command
zcli push --serviceId=[idOfTheServiceYouWantToBuild]
zcli push --serviceId=[idOfTheServiceYouWantToBuild]
if you don't pass in --serviceId, it will let you choose interactively by default, this will match the target service's hostname with the setup definition of your zerops.yml, but if you have 10 apps with essentially the same build and deploy configuration, you can either do what @Jan Saidl suggested
zcli push --serviceId=[idOfTheServiceYouWantToBuild] --setup=appbase
zcli push --serviceId=[idOfTheServiceYouWantToBuild] --setup=appbase
this will force it to use appbase setup no matter the service hostname alternatively you can add one setup base and then have other setups (matching their service's hostname) extend it
zerops:
- setup: appbase
build:
base: nodejs@22
buildCommands:
- npm i
- npm run build
deployFiles:
- dist
run:
base: nodejs@22
ports:
- port: 3000
httpSupport: true
start: node dist/analog/server/index.mjs

- setup: appone
extends: appbase

- setup: apptwo
extends: appbase

- setup: appthree
extends: appbase
zerops:
- setup: appbase
build:
base: nodejs@22
buildCommands:
- npm i
- npm run build
deployFiles:
- dist
run:
base: nodejs@22
ports:
- port: 3000
httpSupport: true
start: node dist/analog/server/index.mjs

- setup: appone
extends: appbase

- setup: apptwo
extends: appbase

- setup: appthree
extends: appbase
elite-benni
elite-benniOP2mo ago
Nice thanks, I will try that and give you the feedback. Very nice, works like expected! Thanks for the help 🥳

Did you find this page helpful?