Pharmaverse and containers | R bloggers

Pharmaverse and containers | R bloggers

5 minutes, 46 seconds Read

[This article was first published on pharmaverse blog, and kindly contributed to R-bloggers]. (You can report a problem with the content on this page here)


Want to share your content on R bloggers? click here if you have a blog, or here if you don’t.


Streamlining our Pharmaverse blog: reducing publishing time with containers

As an active contributor to the pharmaverse blog, I have always appreciated the opportunity to share new insights and tools with our community. The Pharmaverse blog has some interesting publishing options. While the blog publishing process was effective, I wondered if there was a way to optimize our workflows. Currently, it typically took about 17 minutes to put a new post into the CI/CD blog publishing pipeline. Containers are always used as a solution. Unfortunately I wasn’t sure how to create a new container/image to meet my needs and relied on a few simple steps install.packages() in the CI/CD pipeline. Luckily, I came across the fantastic Maciej Nasinski and we built a specific container for the publishing process for the pharmaverse blog, which allowed for a remarkable reduction in publishing time.

Below I discuss how the Pharmaverse container image improved our blog’s publishing workflow, reducing our implementation time to about 5 minutes. We’re also interested in feedback on possible other uses for this container (such as devcontainers) or building additional containers for certain purposes. For those interested, we would be happy to provide a tutorial on containers or contact you if you have any ideas or would like to get involved!

The previous approach: Package installation overhead

Our previous CI/CD (GitHub Actions) workflow for building and deploying the Pharmaverse blog, while extensive, also included a time-consuming step. It used the direct “Install Dependencies” step from the r-lib actions, which required installing a series of Pharmaverse-specific R packages during each run. As we added more packages to the Pharmaverse to the blog, this became very cumbersome!

The relevant part of our old construction implementation task highlighted this:

  build-deploy:
    # ... other configurations ...
    steps:
      # ... checkout and setup Quarto ...
      - name: Setup R
        uses: r-lib/actions/setup-r@v2
        with:
          use-public-rspm: true

      - name: Install dependencies
        uses: r-lib/actions/setup-r-dependencies@v2
        with:
          packages: |
            jsonlite
            tidyverse
            spelling
            janitor
            diffdf
            admiral
            admiralonco
            # ... and many, many more packages ...
            haven
      # ... other steps like install tinytex and publish ...

This “Install Dependencies” step, which involved a substantial list of Pharmaverse packages, was a major contributor to the 17 minute execution time. Each workflow run required these packages to be downloaded and configured, extending the overall deployment time.

Adopting the Pharmaverse container image: an efficient alternative

The solution to this challenge came with the introduction of the Pharmaverse container image: ghcr.io/pharmaverse/docker_pharmaverse:4.5.1. This container image is specifically designed for pharmaceutical data analysis and includes more than 40 essential Pharmaverse packages pre-installed. These packages include various functionalities, including CDISC ADaM/SDTM, clinical trial reporting and regulatory submissions. Built on the rocker/tidyverse image, it includes R 4.5.1 and provides a preconfigured environment.

By integrating this image into our CI/CD pipeline (GitHub Actions), we were able to bypass the extensive package installation phase.

Here’s an overview of our updated build deployment task:

  build-deploy:
    needs: Update-post-dates
    runs-on: ubuntu-latest
    container:
      image: "ghcr.io/pharmaverse/docker_pharmaverse:4.5.1"
    permissions:
      contents: write
    steps:
      - name: Check out repository
        uses: actions/checkout@v4

      - name: Configure Git safe directory
        run: git config --global --add safe.directory /__w/blog/blog

      - name: Set up Quarto
        uses: quarto-dev/quarto-actions/setup@v2
        with:
            version: 1.9.12

      # NOTE: Explicit R package installation is no longer required here.

      - name: Install tinytex
        run: quarto install tool tinytex

      - name: Mark repo directory as safe
        run: git config --global --add safe.directory /__w/blog/blog

      - name: Publish
        uses: quarto-dev/quarto-actions/publish@v2
        with:
          path: . # Path to your .qmd file
          target: gh-pages  # Target branch for GitHub Pages
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The result of this change is a consistent reduction in publication time. Our blog will now be published in about 5 minutes. Yes!

Broader applications of the Pharmaverse Container Image

While this update directly benefits the publication of our blog, the Pharmaverse container image provides broader utility. It is a valuable resource for:

  • Pharmaceutical data analysis: supporting tasks related to ADaM, SDTM and TLFs.
  • Clinical Trial Programming: Assist with regulatory submissions.
  • Reproducible research: providing a consistent and verifiable environment.
  • Training & education: Offering a ready-made setup for educational purposes.
  • CI/CD Pipelines: Improving automated testing and reporting as observed in our own workflow.
  • Collaborative development: Facilitating consistent environments across teams.

Example: Running reproducible RStudio locally

To boot a local RStudio instance using the Pharmaverse image, you can use a container ‘one-liner’. This command condenses the entire configuration (network, storage, and background execution) into a single execution sequence. It connects your local directory to the container, allowing you to edit files “on the fly” without installing R or packages on your actual machine.

Choose the command that corresponds to your operating system:

1. Linux and Intel Macs (standard)

For standard architecture, we set a simple password (rstudio) and mount the current folder.

docker run -d --name my_pharma_rstudio --rm -p 8787:8787 -e PASSWORD=rstudio -v "$(pwd)":/home/rstudio/project ghcr.io/pharmaverse/docker_pharmaverse:4.5.1

2.Apple Silicon (M1/M2/M3)

Remark: We do not yet support the ARM64 architecture by default (e.g. Apple Silicon). The command below uses emulation (--platform linux/amd64) to output the image. We also disable authentication because the slower emulation speed can sometimes cause password setting to time out.

docker run -d --name my_pharma_rstudio --rm --platform linux/amd64 -p 8787:8787 -e DISABLE_AUTH=true -v "$(pwd)":/home/rstudio/project ghcr.io/pharmaverse/docker_pharmaverse:4.5.1

What does this command do?

  • **--rm & -d**: Runs the container in the background (detached) and automatically deletes it when stopped, keeping your machine clean.
  • -v "$(pwd)":...: Takes your Ptake offense Worganize Dictory and mounts it in the container. Any file you save to RStudio’s “project” folder is immediately saved to your local computer.
  • --platform linux/amd64 (Mac only): Forces your computer to emulate the Intel architecture required by the image.
  • -e DISABLE_AUTH=true (Mac only): Bypasses the login screen to ensure direct access despite slower emulation speeds.

Access to RStudio

Once the command is executed:

  1. Open your browser to http://localhost:8787.
  2. Linux/Intel: Log in with user rstudio and password rstudio.
  3. Apple Silicon: You will be logged in automatically.

You will see that your local files have been mapped to the project folder in the Files panel, ready for analysis.

Last updated

18-01-2026 22:21:19.079894

Details

Reuse

Quote

BibTeX quote:

@online{straub_and_maciej_nasinski2026,
  author = {Straub and Maciej Nasinski, Ben},
  title = {Pharmaverse and {Containers}},
  date = {2026-01-18},
  url = {https://pharmaverse.github.io/blog/posts/2026-01-18_pharmaverse_containers/pharmaverse_and__containers.html},
  langid = {en}
}

For source citation, you can cite this work as:

Straub and Maciej Nasinski, Ben. 2026. “Pharmaverse and containers.” January 18, 2026. https://pharmaverse.github.io/blog/posts/2026-01-18_pharmaverse_containers/pharmaverse_and__containers.html.


#Pharmaverse #containers #bloggers

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *