Prevent Redownload of unmodified containers

So I use a raspberrry pi 3b+ with the 64bit balenaOS image. this serves as my octopi server. I then run code-server so I can access my octopi server files as needed.

I recently deployed a krist miner (cryptocurrently for minecraft, holds no real world value), and noticed that when I deployed it with this config

# ./krist-miner/Dockerfile
FROM golang:alpine3.14

ENV WALLET=k33twky32z

RUN apk update
RUN go install github.com/1lann/krist-miner/cpu-miner@latest

CMD ["sh", "-c", "cpu-miner ${WALLET}"]
# unnessecary code for example removed
version: '2'
services
  krist-miner:
    build: ./krist-miner
    container_name: krist
    environment:
      - WALLET=k6kfp19v9k
    restart: unless-stopped

I noticed that it rebuilt the un-modified containers alongside the new one. forcing my pi to download 1.7 gigabytes of data. And it does this every time I make a small config, such as changing an environment variable in a container.

Is there a way I can prevent it from re-building/downloading unmodified containers? My local folder containing my balena config, is a git enabled folder with a git repository on gitlab.

Delta updates should be standard if you are running a recent version of balenaOS Delta updates - Balena Documentation

So if you haven’t changed anything in the container it shouldn’t download anything at all AFAIK

Guessing it might be a typo but in the above it should be services: not services

Hi @merith-tk,

By what mechanism do you tell that the Pi is downloading 1.7Gb of data per config change? Could you paste an example of this, such as logs or networking monitoring? Thanks!

Regards,
Christina

I’d suggest specifying the WALLET env var via balena’s Device Variables section on the dashboard, instead of adding it to the dockerfile. I’m guessing you are modifying WALLET and running balena push again, and you can avoid this by using an env var from the dashboard instead.

The “storage” meter on the dashboard, it reaches nearly full when updating and sits around 1.3gb used now, but when it updates it doubles before it is finnished downloading the updates and then deleting the old one

and the WALLET env is fixed basically, the problem comes from when I tweak even the tiniest setting anywhere in Dockerfile or docker-compose.yml

Hello @merith-tk,

The “storage” meter on the dashboard, it reaches nearly full when updating and sits around 1.3gb used now, but when it updates it doubles before it is finnished downloading the updates and then deleting the old one

I did not clearly understand what you wish to state here ^^. Could you please rephrase?

A reliable (yet easy) way to measure n/w traffic is by using the ifconfigcommand. For every interface ifconfig prints the number of bytes sent & received on the last line (for e.g RX bytes:3366093 (3.2 MiB) TX bytes:3990546 (3.8 MiB)). The difference between ‘RX bytes:’ after & before containers get updated on the device should give you the precise number of bytes downloaded by your RPi.
If you are not sure which interface is being used to download the update, then you can refer to the output of route -n. That should help you in figuring out the interface being used to reach the Internet.

Thanks and regards,
Pranav

Hi @merith-tk! Just complementing what others have said above: using delta updates (they are enabled by default), your device will only download the changes between the image you are currently running and the new one. If you look at the “storage gauge” on the dashboard you’ll indeed see a relatively large increase in the amount of storage used – but not all of this data is being downloaded. Instead, the data on storage is being reconstructed from the current image you already have and the (typically) small delta that is downloaded.