Truenas Scale Electric Eel docker compose with dockerfile_inline?

Hi All,

Since the removal of k3s and the addition of docker compose, i’ve been trying to port over some of things I’ve had and struggling a bit. I’m much more familiar with helm rather than docker compose. I’ve had a look at the implementation (the python framework here: githubdotcom/truenas/apps) and as far as i can tell it seems like the container class should support this feature (githubdotcom/truenas/apps/blob/f97759423fdccd65d0c16724a0400d305b75b5c6/library/2.1.8/container.py#L303) yet i’ve been having all kinds of trouble to get this working.

The main problem i seem to be hitting is args are not being passed through to the building of the container? As the below docker compose manifest results in the posted error message in /var/log/app_lifecycle.log

name: onedev
services:
  onedev:
    image: 1dev/server:11.6.9
    restart: on-failure:5
    ports:
      - 30010:6610
      - 30011:6611
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - REDACTED:/opt/onedev
    environment:
      initial_user: REDACTED
      initial_password: REDACTED
      initial_email: REDACTED
      initial_server_url: REDACTED
      hibernate_connection_password: REDACTED
      hibernate_dialect: io.onedev.server.persistence.PostgreSQLDialect
      hibernate_connection_driver_class: org.postgresql.Driver
      hibernate_connection_url: jdbc:postgresql://postgres:5432/REDACTED
      hibernate_connection_username: REDACTED
    deploy:
      resources:
        limits:
          cpus: "2"
          memory: "2147483648"
    healthcheck:
      test: curl --silent --fail http://localhost:6610/
      timeout: 5s
      interval: 10s
      retries: 5
      start_period: 10s
    depends_on:
      postgres:
        condition: service_healthy
        required: true
      proton-bridge:
        condition: service_healthy
        required: true
  postgres:
    image: postgres:14-alpine3.15
    restart: on-failure:5
    expose:
      - "5432"
    volumes:
      - REDACTED:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: REDACTED
      POSTGRES_USER: REDACTED
      POSTGRES_DB: REDACTED
    deploy:
      resources:
        limits:
          cpus: "1"
          memory: "1073741824"
    healthcheck:
      test: pg_isready -h 127.0.0.1 -p 5432 -d REDACTED -U REDACTED
      timeout: 5s
      interval: 10s
      retries: 5
      start_period: 10s
  proton-bridge:
    build:
      args:
        - PROTON_BRIDGE_VERSION=3.16.0
      dockerfile_inline: |
        FROM golang:1.21.9 as build
        ARG PROTON_BRIDGE_VERSION
        RUN apt-get update && apt-get install -y libsecret-1-dev
        RUN git clone https://github.com/ProtonMail/proton-bridge.git
        WORKDIR proton-bridge
        RUN git checkout tags/v$PROTON_BRIDGE_VERSION
        RUN sed -i 's/Host = "127.0.0.1"/Host = "0.0.0.0"/g' internal/constants/constants.go
        RUN make build-nogui
        FROM debian:12.8-slim
        COPY --from=build /go/proton-bridge /opt/proton-bridge
        RUN ln --symbolic /opt/proton-bridge/proton-bridge /bin/proton-bridge
        RUN apt-get update && apt-get install -y --no-install-recommends \
            gnupg \
            pass \
            libsecret-1-dev \
            && rm -rf /var/lib/apt/lists/*
        RUN gpg --batch --passphrase "" --quick-gen-key "ProtonMail Bridge" default default never
        RUN pass init "ProtonMail Bridge"
        EXPOSE 1025
        EXPOSE 1143
        CMD echo "login\n$PROTON_EMAIL\n$PROTON_PASSWORD" | proton-bridge --cli      
      tags:
        - inline-proton-bridge:custom
    image: inline-proton-bridge:custom
    restart: on-failure:5
    ports:
      - 30025:1025
      - 30043:1143
    volumes:
      - REDACTED:~/.local/share/protonmail
    environment:
      PROTON_EMAIL: REDACTED
      PROTON_PASSWORD: REDACTED
    deploy:
      resources:
        limits:
          cpus: "1"
          memory: "536870912"
    healthcheck:
      test: curl --silent --fail imap://$PROTON_EMAIL:$PROTON_PASSWORD@localhost:1143/
      timeout: 5s
      interval: 10s
      retries: 5
      start_period: 10s
[2025/01/11 13:53:47] (ERROR) app_lifecycle.compose_action():56 - Failed 'up' action for 'onedev' app:
time="2025-01-11T13:53:41+10:00" level=warning msg="The \"PROTON_BRIDGE_VERSION\" variable is not set. Defaulting to a blank string."
time="2025-01-11T13:53:41+10:00" level=warning msg="The \"PROTON_EMAIL\" variable is not set. Defaulting to a blank string."
time="2025-01-11T13:53:41+10:00" level=warning msg="The \"PROTON_PASSWORD\" variable is not set. Defaulting to a blank string."
time="2025-01-11T13:53:41+10:00" level=warning msg="The \"PROTON_EMAIL\" variable is not set. Defaulting to a blank string."
time="2025-01-11T13:53:41+10:00" level=warning msg="The \"PROTON_PASSWORD\" variable is not set. Defaulting to a blank string."
 proton-bridge Pulling 
 proton-bridge Warning pull access denied for inline-proton-bridge, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
failed to solve: process "/bin/sh -c git checkout tags/v" did not complete successfully: exit code: 1

has anyone else used this feature? or has the team confirmed this is fully implemented? is there anything obvious im doing wrong? i could totally accept this is a me problem as i previously mentioned im quite new to the docker compsoe world, i come from the kubernetes world :slight_smile:

any help would be greatly appreciated!

I can’t edit my OP apparently, but i should have mentioned obviously this works locally when I have the Dockerfile and run the following:

docker build --build-arg PROTON_BRIDGE_VERSION=3.16.0 --tag inline-proton-bridge:custom --file Dockerfile .

docker run --rm -it -e PROTON_EMAIL=REDACTED -e PROTON_PASSWORD=REDACTED inline-proton-bridge:custom

So this seems to be a truenas apps problem.

And just to circle back one last time, if i remove the args and environment values and just hardcode them inside the dockerfile_inline block this all works as expected. So definitely these values are not being passed into correctly when truenas does a docker build under the hood.

1 Like

This is when creating a custom app and pasting in a compose file, is that right?

Do you know whether running compose from command line works? And the restart parameters are honored on reboot?

As in, just run a compose, don’t create a custom app for it.

ugh, turns out I was just being bitten by string interpolation :cry:

for full context here is the github issue i put up for this and the resolution given: build args not being passed to dockerfile_inline · Issue #1344 · truenas/apps · GitHub