First roadblock for new user

I was able to get through the getting started and have a Pi3 online running balenaOS 2.27.0+rev1.

I tested successfully the deployment of the Express.js webserver.

Next I want to deply the losant edge as a docker container, but I’m not sure of how:
First remove the above Exprerss.js webserver.
Second, create the needed docker container file, that’s just supposed to contain “FROM losant/edge-agent:latest-arm
EXPOSE 8080/tcp”
Can someone explain where and how to do that ?

Hi @landersson,

I’m pretty new as well but this might help.

I suggest looking at the Dockerfile template from one of the example applications provided:
https://www.balena.io/docs/reference/base-images/base-images/

This is basically where you define the container configuration for your application, and push this to Balena. You need to target ARM architecture and using the losant image as your base with the FROM command, and then add the Expose command to expose port 8080 to the host machine.

Further info on Dockerfile templates:

If unfamiliar with Docker I would suggest having a look at:

Cheers
Chris

Still not clear

Should the docker container not run on top of the Balena Os?

Or do I need to start over with download an os to the Pi’s SF card?

Hi there,

Your application does indeed run as a Docker container on top of BalenaOS.

We’d recommend using a new application to start your own project, which would involved reprovisioning the Pi. However, if you want to use the same application that is already provisioned, you could create a new git repo, add your new Dockerfile, source, etc., then add the Balena git remote (the line in the Dashboard for the application), and then git push --force balena master to force the new git repository to be used.

Please let us know if you need any other help with this.

Best regards,
Heds

That sounds like what I have tried to do, but I must be missing something major.

Can you explain more in detail I could use the same application for my losant edge deploy ?

Sure,

I would start with a simple docker-compose.yml file comprising of the following:

version: "2"
services:
  losant:
    image: losant/edge-agent:latest-arm
    ports:
    - "8080:8080"

This is telling Balena’s supervisor to use the losant image, and bind port 8080 on the container to the host. Create an empty directory for your project, put this file in that directory, then on a terminal prompt do a git push as Heds mentions above.

Give this a try and if it doesn’t work then please post back here an output from the following commands:

  • ls -la
  • git push --force balena master

This is where I’m lacking experience…
When you say: “create an empty directory for your project”, do you mean that I should open gitbash and just create a new directory to put the file in, or is there some other git commands I should be using?

Here are my outputs from the command you mentioned above:
$ ls -la
total 33
drwxr-xr-x 1 lande 197609 0 Dec 20 15:39 ./
drwxr-xr-x 1 lande 197609 0 Dec 20 15:39 …/
drwxr-xr-x 1 lande 197609 0 Dec 20 15:39 .git/
-rw-r–r-- 1 lande 197609 106 Dec 20 15:34 docker-compose.yml

$ git push --force balena master
error: src refspec master does not match any.
error: failed to push some refs to ‘balena’

@landersson
Looks like you did not create the remote in git:
git remote add balena @git.balena-cloud.com:/.git
This links your git repository to the remote repository in balena using your balena username and the application name you choose when creating the application in the balena dashboard.
You can get the full command from the balena dashboard (upper right corner) when in your application.
Not quite sure if you went through the process of creating a user and application in balena, otherwise follow the getting started guide :
https://www.balena.io/docs/learn/getting-started/raspberrypi3/nodejs/

Skip the cloning of an existing repository and use the repository you created instead.

I did do that when I went through the guide you mentioned. And I was able to get the example webserver working, but now I want to deploy the Losant edge agent. Do I need to remove the test web server first?
If so , how do I do that?.

I gather you want to reuse the application containing of the web server. It is probably less messy if you just create a new application for this project following the guide again but not cloning any existing repository.
Then you grab the git remote add command from the dashboard and apply it to the new repository you created earlier by just running it in that directory.
After that you should be able to push it. Problem is you need to download and flash a new image to your device.

If you want to reuse the existing application / device you could just delete everything except the .git directory from the project folder you created for the web server and then copy your docker-compose.yml into the folder.
Then
git add .
and
git commit
and finally
git push --force balena master

Forgot to reply that I got it to work based on your help. Thanks
Now I need to update the Losant agent.
How do I do that easiest?

You have to push a commit to the balena remote.
I’m not sure if balena will notice a change to the dockerfile for the losant/edge-agent:latest-arm
so you may have to change that to a specific commit or version.

I have tried changing the .yml file to have a different version, but it tells me “no changes added to commit”

Can you include the .yml file here?
Where are you seeing the “nothing added to commit” error? Did you “git add --all”?

version: “2”
services:
losant:
image: losant/edge-agent:latest-arm
ports:
- “8080:8080”

Try specifying a specific version as described at https://docs.losant.com/edge-compute/edge-agent-installation/

So replace “latest” with 1.5
See https://docs.losant.com/edge-compute/edge-agent-installation/

I tried that before, but it didn’t work.

Now I have another issue. When trying the above again and :git push balena master" , I get this:

[Error] Could not parse compose file
[Error] Unsupported composition version
[Error] Not deploying release.

remote: error: hook declined to update refs/heads/master
To git.balena-cloud.com:xxxxxxxxx/testing.git
! [remote rejected] master -> master (hook declined)
error: failed to push some refs to ‘xxxxxx@git.balena-cloud.com:xxxxxxx/testing.git’

I started from scratch and it looks like the docker image is updating now.

update. it appears it pulled the same image as it was using.