I have successfully installed the Balena OS on my Raspberry Zero W with service balena-cam and now I want to add another service (wifi-connect): how to do this?
I got this error when I try to push the wifi-connect repo: git push balena master
! [rejected] master → master (fetch first)
error: failed to push some refs to [BALENA USERNAME:.git]
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
Welcome to the balena Forums! If you used Deploy with balena for your initial push, you don’t yet have the GitHub repo files on your workstation or any local reference to the remote repo. That means you’ll first need to do a git add repo <git remote add <repo URL.git> before doing a git push balena master.
That said, pushing a project (a containerized service) from a second repo will not add that to your application. It will replace it. In order to create what we call a multi-container application, you need to clone the different repos to your workstation and copy the Dockerfiles and associated content to one common directory, and update the docker-compose.yml. That is, the updated docker-compose.yml would have two (or more) service stanzas that includes everything from both original single docker-compose.yml files:
I should add that you can either a) push your new combined project to a new GitHub repo you own or install balenaCLI and push the application from your workstation to your Raspberry Pi with balena push <app-name>.
Whenever you push an application, whether with Deploy with balena, balena push or git, the code will replace whatever else was on the device. The fact that you have a container named main suggests you still only have one container/service running. balena-cam and wifi-connect need to be both included in a docker-compose.yml file in your working directory (on your workstation). If you don’t push your changes to a new GitHub repo and instead point to one of the others, that will be deployed, not your code. balena push <app-name> pushes the code you edited on your workstation to the device.
Your combined docker-compose.yml should look something like this: