Issue with Fetching Oban Packages from Private Hex Repo during Docker Build

Hello,

I am encountering an issue while trying to fetch Oban packages from a private Hex repository during the Docker build process for my Elixir Phoenix project.

Steps I’ve Taken:

  1. Verified the repository configuration with mix hex.repo list, and the private repo is correctly listed.
  2. Confirmed the OBAN_AUTH_KEY environment variable is set (also printed it within the Dockerfile).

Dockerfile Context:

I’m using the following RUN command within the Dockerfile to configure the private Hex repository:

dockerfile

RUN --mount=type=secret,id=oban_auth_key \
    mix hex.repo add oban https://getoban.pro/repo \
      --fetch-public-key SHA256:4/OSKi0NRF91QVVXlGAhb/BIMLnK8NHcx/EWs+aIWPc \
      --auth-key "$(cat /run/secrets/oban_auth_key)"

Docker Build Command:

I build the Docker image with:

docker build --secret id=oban_auth_key,env=OBAN_AUTH_KEY .

Error Message:

sql

3.461 remote: Total 9314 (delta 4618), reused 8001 (delta 3786), pack-reused 0 (from 0)        
4.943 Failed to fetch record for oban/oban_web from registry (using cache instead)
4.943 unknown or incorrect license key
4.961 ** (Mix) Unknown package oban_web in lockfile

so one thing that may happen but I did not verify it is that there’s a newline character at the end of the files created for Docker.

Did you check if the file at /run/secrets/oban_auth_key ends with a newline character?

If so, did you try removing it? I think it may be as easy as not using quotes around the command

2 Likes