TLDR: Does Balena Engine / OS recognize
docker-compose.override.yml file or is it disregarded? Is anyone else out there developing Balena applications locally on their laptop using docker before testing on hardware via livepush? Appreciate any feedback on best workflow.
I’m working on a better TDD workflow for a microservice architecture running on BalenaFin but of which the majority of containers do not require hardware interaction. I’ve been playing around with running containers locally using docker with huge improvements on speed running tests and simply not having to deal with livepush connection issues which happen frequently for us. But, how to switch between both local docker engine and Balena on the Fin without constantly changing production compose files on feature branches has been a topic of investigation, especially as I’m building this workflow for our entire team.
Conflicts with Balena Engine:
Balena does not yet support alternate compose files
My current understanding is that switching between compose configurations is not available with Balena Engine. We do not have the option to pass an alternative compose file as an argument for Balena build/push such as
Balena does not allow build-arg before from
We also do not have the option of using
FROM in container docker files so we cannot template the base image.
Balena only supports %%BALENA_MACHINE_NAME%%
I do understand that Balena has support for templating architectures in the dockerfile. However, my assumption is that this only works when using balena, which if I was to use locally on my laptop would require VirtualBox VM which seems overkill since everyone on our team already has docker engine and docker desktop installed on thier computers. Ideally we could simply
docker compose build up and start developing and running tests on containers.
Best Solution So Far:
My best solution has been to use
docker-compose.override.yml to adjust my compose file locally on my development laptop running docker. Pytest runs ~5x faster on amd64 vs fincm3 which is amazing. From testing, I believe that Balena Engine does not recognize the docker override file and so this actually works out pretty well for local development and I can also instantly push to our local mode device at anytime via livepush without conflict. But I’d be curious to hear from the Balena team if ignoring the override file is a predictable behavior of Balena Engine/OS?
I’ve detailed an example docker-compose and docker-compose.ovveride setup below. My current thought is to keep a docker override template file in our repo that developers can customize during feature development untracked in their local feature branch. I have to believe folks out there are doing this already, but could not find specific examples from the forum.
version: '2' services: redis: build: context: ./redis dockerfile: Dockerfile_fincm3 expose: - "6379" ports: - "6379:6379" volumes: - 'redis-data:/redis-data' my-service: build: context: ./my-service dockerfile: Dockerfile_fincm3 expose: - "80" ports: - "84:80" depends_on: - redis
version: '2' services: my-service: build: # Change to dockerfile using # generic-x86 base image.. dockerfile: Dockerfile_x86 volumes: # bind volume for local development - ./map-service2:/usr/src/app redis: build: # Change to dockerfile using # amd64 base image.. dockerfile: Dockerfilex_86