Installing a Bitbucket package in a Docker image when it has a dependency on another Bitbucket package

I'm trying to install a Bitbucket package in a Docker image. The command to do this in my Dockerfile is:

RUN --mount=type=secret,id=bitbucket_password . /run/secrets/bitbucket_password && R -e "remotes::install_bitbucket(repo='myorg/afp.model',ref='v0.1.1',auth_user='$BITBUCKET_USER',password='$BITBUCKET_PASSWORD')"

The problem is this package has a dependency on another of our packages afp.data which I've specified in the Remotes section of the package as:

Remotes: 
    bitbucket::myorg/afp.data@v0.2.2

When I try to build the package I get the following error at the console:

Error: Failed to install 'afp.model' from Bitbucket:
  cannot open URL 'https://api.bitbucket.org/2.0/repositories/myorg/afp.data/commit/v0.2.2'

I've already passed in my username and password, and I am able to install our other packages that don't have such dependencies, so I'm not sure why it can't open that URL (if it's a permissions issue)?

Would appreciate any help in troubleshooting this. :slight_smile: