How to deploy an Actyx app inside a container using Balena

Hello,

I’m trying to deploy an app inside a container using Balena. Do you have some documentation to guide me in this process?

Kind regards,
Carlos Dias.

Hi Carlos :wave: ,

we have two scenarios to keep in mind:

  1. Headless applications (i.e. PLC Connectors or DB Exporters)
  2. UI applications running on mobile devices or desktops

For the first scenario, you’d use the stock actyx/os image from Docker Hub and one image containing your headless app.
See below for an example Dockerfile and docker-compose.yml illustrating this. We use similar ones to describe our Balena deployments.

For the second scenario, we recommend using frameworks like Apache Cordova, Flutter or React Native for mobile and Electron for desktop apps.

Running UI applications on Docker is an unusual scenario, since the UI would typically only be served from within the container but executed in the browser on the client. From there it would communicate with Actyx on the client node. While this manages the delivery of the application to the device, it does not manage deploying Actyx on the device.

AFAIK, this is not something Balena supports, but mobile device management services like AirWatch (which we also use in production) do.

So the recommended approach for building and deploying UI applications is to build and package your application for your target devices and deploy both application and Actyx using an MDM system or service.

You also might want to take a look at axp, our tool for working with Actyx projects, which supports you setting up apps in the manner described above.

Dockerfile

FROM node:10-alpine as build
WORKDIR /usr/src/app

COPY src/my-application/package.json ./package.json
RUN npm install --production
COPY build/my-application/. .

FROM node:10-alpine
COPY --from=build /usr/src/app /
CMD ["node", "my-application/index.js"]

docker-compose.yml

version: 2.1

volumes:
  actyxos-data:

services:
  actyxos:
    image: actyx/os:1.1.2-x64
    ports:
      - 4001:4001
      - 4457:4457
    volumes:
      - actyxos-data:/data
    privileged: true
    environment:
      AX_DOCKER_BIP: ...
      ENABLE_DEBUG_LOGS: 1
      AX_DEV_MODE: 1
    restart: always


  my-application:
    image: my-application
    environment:
      MY_APP_SETTING_1: something 
    restart: always
    

Does this help, or do you have further questions?