Create-production-image fails with JSON exception

I am trying to create a production image for my project.

The create-production-image task fails on the step where it goes to make a new docker-compose.yml.

The exception looks like this:

Executing task: xonsh /home/jzylkin/repos/chipotle_dbpt/.conf/create-docker-compose-production.xsh /home/jzylkin/repos/chipotle_dbpt v0.0.0 chipotle -imx8 



❌ Error: JSONDecodeError('Expecting value: line 891 column 13 (char 30764)')
Error cause: User fault

xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/home/jzylkin/repos/chipotle_dbpt/.conf/create-docker-compose-production.xsh", line 157, in <module>
    xonsh ./.vscode/tasks.xsh run run-torizon-binfmt
    
  File "/home/jzylkin/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/built_ins.py", line 220, in subproc_captured_hiddenobject
    return xonsh.procs.specs.run_subproc(cmds, captured="hiddenobject", envs=envs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jzylkin/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/procs/specs.py", line 1107, in run_subproc
    return _run_specs(specs, cmds)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jzylkin/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/procs/specs.py", line 1153, in _run_specs
    cp.end()
  File "/home/jzylkin/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/procs/pipelines.py", line 481, in end
    self._end(tee_output=tee_output)
  File "/home/jzylkin/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/procs/pipelines.py", line 500, in _end
    self._raise_subproc_error()
  File "/home/jzylkin/.local/pipx/venvs/xonsh/lib/python3.11/site-packages/xonsh/procs/pipelines.py", line 646, in _raise_subproc_error
    raise subprocess.CalledProcessError(rtn, spec.args, output=self.output)
subprocess.CalledProcessError: Command '['xonsh', './.vscode/tasks.xsh', 'run', 'run-torizon-binfmt']' returned non-zero exit status 69.

 *  The terminal process "xonsh '/home/jzylkin/repos/chipotle_dbpt/.conf/create-docker-compose-production.xsh', '/home/jzylkin/repos/chipotle_dbpt', 'v0.0.0', 'chipotle', '-imx8'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

My docker-compose.yml file looks like this:


services:

  chipotle-debug:
    build:
      context: .
      dockerfile: Dockerfile.debug
    network_mode: host
    image: ${LOCAL_REGISTRY}:5002/chipotle-debug:${TAG}
    ports:
      - ${DEBUG_SSH_PORT}:${DEBUG_SSH_PORT}
      - ${DEBUG_PORT1}:${DEBUG_PORT1}

  chipotle:
    network_mode: host
    build:
      context: .
      dockerfile: Dockerfile
    image: ${DOCKER_LOGIN}/chipotle:${TAG}

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for sharing the details of your issue.

Your traceback, combined with the JSONDecodeError pointing to line 891 of a file being processed, suggests a syntax issue or an environment variable handling problem in your docker-compose.yml during the production image generation step.

Here are steps to help you resolve the issue:

1. Check Environment Variables Handling

Recent versions of TorizonCore Builder and related tools no longer automatically expand environment variables in compose files—you must ensure all needed variables are defined when running the production image creation step.

Variables you need to define:

  • LOCAL_REGISTRY
  • DEBUG_SSH_PORT
  • DEBUG_PORT1
  • DOCKER_LOGIN
  • TAG

Define these variables either in your shell before running the task, in a .env file, or directly in your CI/CD system.

Tip: If you intend for some variables (like ${TAG}) to remain unexpanded until runtime, escape them using a double dollar sign: ${{TAG}}$$TAG. This prevents premature expansion during the image creation process.

More info:


2. Review for JSON/YAML Syntax

The error JSONDecodeError('Expecting value: line 891 column 13 (char 30764)') suggests a possible formatting or syntax problem. Even though docker-compose files are YAML, intermediate processing by tooling can trip up on errors that look like JSON issues.

Actions:

  • Open your docker-compose.yml and carefully check lines near the mentioned location (if your file isn’t that long, look towards the end for unexpected syntax like missing quotes, colons, or indentation issues).
  • Check for stray or missing characters, especially in blocks with environment variables and ports.

3. Remove or Adjust the build Section

When the create-production-image task runs, it will strip build sections from production services and expects image fields to be fully defined. Ensure that your services have an image field, and the build section is not strictly necessary during production bundling.


4. Simplify and Isolate

If the error persists, try simplifying your docker-compose.yml to the minimal configuration (one service, less variables), then rebuild. Gradually reintroduce complexity to identify the line or construct causing the error.


Example Service Block

services:
  chipotle:
    image: ${DOCKER_LOGIN}/chipotle:${TAG}
    network_mode: host

Ensure all variables (DOCKER_LOGIN, TAG) are defined during the production step.


If you apply these checks and validations, your production image creation should complete successfully.

For further reading and troubleshooting steps:

Best regards,
Toradex AI Assistant.

I figured this one out – there was an errant comma in my vscode tasks.json file on line 891. It did not bother the vscode task runner, but it does seem to bother the xsh script that runs tasks.

Thanks for your help. You can consider this ticket resolved.