splor-mg / atividades

Gestão de tarefas
0 stars 0 forks source link

Utilizar `renv::install()` para instalação de pacotes de repositórios privados #67

Open fjuniorr opened 11 months ago

fjuniorr commented 11 months ago

Your project may make use of packages which are available from remote sources requiring some form of authentication to access – for example, a GitHub enterprise server. Usually, either a personal access token (PAT) or username + password combination is required for authentication. renv is able to authenticate when downloading from such sources, using the same system as the remotes package. In particular, environment variables are used to record and transfer the required authentication information.

Remote Source Authentication
GitHub GITHUB_PAT
GitLab GITLAB_PAT
Bitbucket BITBUCKET_USER + BITBUCKET_PASSWORD
Git Remotes GIT_PAT / GIT_USER + GIT_PASSWORD

These credentials can be stored in e.g. .Renviron, or can be set in your R session through other means as appropriate.

-- Installing packages • renv

fjuniorr commented 9 months ago

No projeto dos volumes da LOA estou usando a flag --secret durante o docker build. Isso expõe um arquivo do host dentro do container de forma segura, no entanto eu não consigo controlar o nome que esse arquivo vai ter dentro do container. Copiar para o arquivo .Renviron dentro do container e depois deletar não é uma opção porque ainda vai ficar nas layers do docker.

fjuniorr commented 9 months ago

A vignette Using renv with Docker • renv não menciona esse caso de uso. Mas achei essa frase que chamou minha atenção:

At work I use a number of internal packages stored in a private CRAN that rely on authentication through HTTP (basic HTTP access with username/password in the URL or bearer authentication with a token in the header).

The approach here to install with a running container makes it easy to share these credentials as environment variables with e.g. a -e argument to a docker run.

This is very different from trying to install packages at build time, because it is difficult to make environment variables availabe in a non-persistent manner at image build time.

-- https://github.com/robertdj/renv-docker#private-crans