Trouble with System.Cmd with fly.io Deployment

Hello,

I have a Phoenix app deployed to fly.io that requires the execution of two external binaries, specifically pdftk and pdfinfo (which is part of the poppler-utils) package.

I have this line in my docker file:
RUN apt-get update -y && apt-get install -y build-essential git npm pdftk poppler-utils && apt-get clean && rm -f /var/lib/apt/lists/*_*

My assumption was that including the packages here would make them available to the Phoenix app, but the app functionality that requires them fails, and I cannot run them using System.cmd in the remote iex environment.

Any help would be greatly appreciated.

What happens when you try? The error message will likely help folks troubleshoot.

When I run System.cmd("sh", ["-c", "pdftk"] in the iex session on the fly machine it outputs this:

{"", 127}

Which I believe is the error for the command not being in the PATH.

If you know the path to the executable, try with calling that.

I figured it out. Rookie mistake…

I wasn’t installing them with the apt-get install command under the FROM ${RUNNER_IMAGE} line in the Docker file, so the packages weren’t actually being installed on the deployed machine. Adding them here solved my problem:

FROM ${RUNNER_IMAGE}

RUN apt-get update -y && \
    apt-get install -y libstdc++6 openssl libncurses5 locales ca-certificates pdftk poppler-utils \
    && apt-get clean && rm -f /var/lib/apt/lists/*_*
``
2 Likes