Skip to content

Using Gitlab's deploy tokens with pak, without having git installed #65

@david-vicente

Description

@david-vicente

I don't know if this is a Pak issue, or a gitcreds issue. So sorry in advance.

Gitlab has a feature called group deploy tokens, that you can use in a number of ways. I'm currently using them to give access to every private repo that my organization/group has on gitlab. So they are like personal access tokens, but for an organization instead.

They follow a username:password scheme, where both components are random strings. So, to have access to a repository I have to add those strings to the url like: "https://username:password@gitlab.com/groupname/reponame".

Because of this gitcreds_cache_envvar gives me GITHUB_PAT_USERNAME_AT_GITLAB_COM.

I want to be able to have

RUN R -q -e 'pak::pkg_install("gitlab::groupname/reponame")'

in a Dockerfile, and build an image without git installed.

The issue is that when Pak runs gitcreds_get, in order to be able to enter this if branch, which returns before checking for git, gitcreds_get_cache will look for the env variable GITHUB_PAT_GITLAB_COM instead of GITHUB_PAT_USERNAME_AT_GITLAB_COM.

Because of this mismatch I'm forced to install git on my image even if I'm trying to use environment variables and not depend on git-credentials stores.


My current Dockerfile is the following:

FROM rocker/r-ver:4

RUN apt-get -y update; apt-get -y install curl git

RUN install2.r --error --skipinstalled --ncpus -1 \
    pak \
    && rm -rf /tmp/downloaded_packages \
    && strip /usr/local/lib/R/site-library/*/libs/*.so

RUN --mount=type=secret,id=gitlab,env=GITHUB_PAT_GITLAB_COM R -q -e 'pak::pkg_install("gitlab::groupname/reponame")'

CMD ["tail", "-f", "/dev/null"]

Notice I'm passing my token as an env variable, so git shouldn't be needed. However to successfully build this image I'm forced to install git in the first RUN instruction because of this issue I'm reporting.

Passing the secret as env=GITHUB_PAT_USERNAME_AT_GITLAB_COM also doesn't work...

Metadata

Metadata

Assignees

No one assigned

    Labels

    reprexneeds a minimal reproducible example

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions