Skip to content

setup .devcontainer#1628

Merged
m7pr merged 13 commits into
mainfrom
devcontainer
Dec 23, 2025
Merged

setup .devcontainer#1628
m7pr merged 13 commits into
mainfrom
devcontainer

Conversation

@m7pr

@m7pr m7pr commented Oct 10, 2025

Copy link
Copy Markdown
Collaborator

An attempt to setup .devcontainer structure so that you can use pre-defined Docker image with R installed And potentially many more R packages LOCALLY in your VS Code or for interactive live github copilot coding environment

Closes

Allows to open VS Code / Cursor in a pre-created docker image that is also used during CI/CD testing


Steps to reproduce - locally in VS Code / Cursor

  • Open VS Code / Cursor on this branch
  • Launch Docker Desktop, or be sure Docker is running on your machine
  • Click in the notification to reopen with devcontainer
image
  • On VS Code it looks like this -> right bottom corner
image
  • The image will be pulled (if it was not pulled before)
image
  • Once the image is pulled, the docker container is started
image
  • Note that this container has 9 GBs
image
  • Now, when opening a terminal, you should be inside the docker container
image
  • You can check the structure of the project inside the container, and you can obviously run R
image
  • You can see brand new packages from CRAN - this is our CI setup
image
  • For the development setup, you would need to install development versions of packages on your own
image
  • You can also see it created a new branch called devcontainer for you to work
image
  • It also created a Workspace for you, that you can always close, when you are done
image
  • Here you can close
image
  • And then you can open again by selecting this workspace
image
  • Final note: by default all folders from your current workspace are added to the container:
    • this is specified by "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind" in .devcontainer.json
    • but the devcontainer needs to be on the same level as all folder like below
image
  • So it opens the devcontainer will all folders included
image
  • Lastly, you can see that each Remote Session with devcontainer starts a docker container
image

Steps to reproduce - remotely in GitHub Codespaces

  • In project main view, click Code -> Create codespace on devcontainer
image
  • You should see a page where the codespace is being created for you
image
  • First Codespace creation is slow with this docker container (9 GB), but once it's created then you can always jump off and on
  • This is how it looks when it's finally launched
image - It has R and teal from CRAN image
  • You can always open the codespace back again from project website
image - And this is how you stop the codespace image

@m7pr m7pr requested a review from Copilot October 10, 2025 12:07
@m7pr m7pr added the core label Oct 10, 2025

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Sets up a development container configuration for R programming with VS Code extensions and language server support. This enables consistent R development environments using Docker containers.

  • Adds .devcontainer/devcontainer.json with R-specific VS Code extensions and settings
  • Creates .devcontainer/Dockerfile with Ubuntu base image and R installation
  • Configures automatic installation of R language server package on container creation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.devcontainer/devcontainer.json Configures dev container with R extensions and post-creation setup
.devcontainer/Dockerfile Defines Docker image with Ubuntu base and R installation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread .devcontainer/devcontainer.json Outdated
m7pr and others added 3 commits December 9, 2025 10:24

Copilot AI commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

@m7pr I've opened a new pull request, #1657, to work on those changes. Once the pull request is ready, I'll request review from you.

@github-actions

github-actions Bot commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

badge

Code Coverage Summary

Filename                          Stmts    Miss  Cover    Missing
------------------------------  -------  ------  -------  ---------------------------------------------------------------------------------------
R/after.R                            59      21  64.41%   42-52, 64, 69, 77-79, 81-89, 100, 104-105
R/checkmate.R                        24       0  100.00%
R/dummy_functions.R                  61       2  96.72%   54, 56
R/include_css_js.R                   11       0  100.00%
R/init.R                            136       0  100.00%
R/module_bookmark_manager.R          99      54  45.45%   78-133
R/module_data_summary.R             177       8  95.48%   40, 50, 205, 236-240
R/module_filter_data.R               64       0  100.00%
R/module_filter_manager.R           207       7  96.62%   116-117, 313, 340, 352, 359-360
R/module_init_data.R                 84       0  100.00%
R/module_nested_tabs.R              371      36  90.30%   163, 267-282, 302-306, 324, 361, 479-482, 486-489, 493-496
R/module_session_info.R              18       0  100.00%
R/module_snapshot_manager.R         272       9  96.69%   302-306, 373, 376-378
R/module_source_code.R               69       0  100.00%
R/module_teal_lockfile.R            131      53  59.54%   45-57, 60-62, 76, 86-88, 100-102, 110-119, 122, 124, 126-127, 142-146, 161-162, 177-186
R/module_teal_reporter.R            122       9  92.62%   60, 77-78, 81, 98, 128, 142, 144, 158
R/module_teal.R                     211       7  96.68%   127, 142-143, 183, 217, 260-261
R/module_transform_data.R           116       6  94.83%   48, 132-136
R/module_validate_error.R            73       0  100.00%
R/modules.R                         291      61  79.04%   170-174, 229-232, 357-377, 385, 391, 568-574, 587-595, 610-625, 658, 670-678
R/reporter_previewer_module.R        41      12  70.73%   41, 45, 68-85
R/teal_data_module-eval_code.R       23       0  100.00%
R/teal_data_module-within.R           7       0  100.00%
R/teal_data_module.R                 20       0  100.00%
R/teal_data_utils.R                  49       0  100.00%
R/teal_modifiers.R                   57       0  100.00%
R/teal_slices-store.R                29       0  100.00%
R/teal_slices.R                      63       0  100.00%
R/teal_transform_module.R            45       0  100.00%
R/TealAppDriver.R                   344     344  0.00%    50-713
R/utils.R                           291      48  83.51%   403-452, 540-549
R/validate_inputs.R                  32       0  100.00%
R/validations.R                      58       0  100.00%
R/zzz.R                              19       0  100.00%
TOTAL                              3674     677  81.57%

Diff against main

Filename      Stmts    Miss  Cover
----------  -------  ------  --------
TOTAL             0       0  +100.00%

Results for commit: e407547

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions

github-actions Bot commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

Unit Tests Summary

  1 files   29 suites   2m 44s ⏱️
399 tests 354 ✅ 45 💤 0 ❌
625 runs  576 ✅ 49 💤 0 ❌

Results for commit e407547.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
module_session_info 💔 $18.14$ $+1.01$ $0$ $0$ $0$ $0$
shinytest2-disable_report 💀 $0.38$ $-0.38$ $-4$ $-4$ $0$ $0$
shinytest2-disable_src 💀 $0.22$ $-0.22$ $-2$ $-2$ $0$ $0$
shinytest2-show-rcode 💀 $0.28$ $-0.28$ $-3$ $-3$ $0$ $0$
shinytest2-teal_modifiers 💀 $0.55$ $-0.55$ $-7$ $-7$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
module_session_info 💔 $18.12$ $+1.01$ srv_session_info_lockfile_creation_process_is_invoked_for_teal.lockfile.mode_enabled_and_snapshot_is_copied_to_teal_app.lock_and_removed_after_session_ended
shinytest2-decorators 👶 $+0.04$ unnamed
shinytest2-disable_report 💀 $0.10$ $-0.10$ Add_to_report_button_is_not_disabled_by_default.
shinytest2-disable_report 💀 $0.09$ $-0.09$ Report_button_is_active_on_a_nested_module_by_default
shinytest2-disable_report 💀 $0.09$ $-0.09$ Report_button_is_disabled_on_a_module_changed_by_disable_report_
shinytest2-disable_report 💀 $0.10$ $-0.10$ Report_button_is_disabled_on_nested_modules_changed_by_disable_report_
shinytest2-disable_src 💀 $0.12$ $-0.12$ Show_R_Code_button_is_disabled_on_a_module
shinytest2-disable_src 💀 $0.10$ $-0.10$ Show_R_Code_is_disabled_on_nested_modules_changed_with_disable_src
shinytest2-reporter 👶 $+0.01$ unnamed
shinytest2-show-rcode 💀 $0.09$ $-0.09$ e2e_Module_with_Show_R_Code_has_code
shinytest2-show-rcode 💀 $0.09$ $-0.09$ e2e_Module_with_Show_R_Code_has_modal_with_two_dismiss_and_two_copy_to_clipboard_buttons
shinytest2-show-rcode 💀 $0.10$ $-0.10$ e2e_Module_with_Show_R_Code_initializes_with_visible_button
shinytest2-teal_data_module 👶 $+0.02$ unnamed
shinytest2-teal_modifiers 💀 $0.08$ $-0.08$ e2e_add_landing_modal_displays_landing_modal_on_app_startup
shinytest2-teal_modifiers 💀 $0.08$ $-0.08$ e2e_add_landing_modal_modal_can_be_dismissed
shinytest2-teal_modifiers 💀 $0.08$ $-0.08$ e2e_combined_modifiers_displays_all_customizations_when_chained_together
shinytest2-teal_modifiers 💀 $0.08$ $-0.08$ e2e_modify_footer_displays_custom_footer_in_the_app
shinytest2-teal_modifiers 💀 $0.09$ $-0.09$ e2e_modify_header_displays_custom_header_in_the_app
shinytest2-teal_modifiers 💀 $0.07$ $-0.07$ e2e_modify_title_sets_custom_title_in_the_page_title_head_title_displays_custom_favicon_in_the_app
shinytest2-teal_modifiers 💀 $0.08$ $-0.08$ e2e_modify_title_sets_custom_title_in_the_page_title_head_title_displays_custom_title_in_the_app

Results for commit e971999

♻️ This comment has been updated with latest results.

…lopment (#1657)

# Pull Request

Configures development environments to provide consistent R development
setup using pre-built Docker images and GitHub Actions.

## Development Container

- Uses `ghcr.io/insightsengineering/rstudio:latest` image with R
pre-installed
- Configures VS Code with R extensions (language support, debugger,
Quarto)
- Sets up R terminal preferences (radian, httpgd plotting)
- Mounts workspace to `/workspace` for consistent paths

## GitHub Copilot Agent Configuration

- Adds `.github/copilot-setup-steps.yml` workflow to configure the
Copilot agent environment
- Uses Docker container with
`ghcr.io/insightsengineering/rstudio:latest` image (same as
devcontainer)
- Verifies R installation with version check and `sessionInfo()`
- Ensures R is available when GitHub Copilot agent works on this
repository
- File must exist in each repository (cannot be referenced from
`r.pkg.template` due to GitHub limitations)

Enables reproducible development environments without local R
installation for both human developers (via devcontainer) and AI agents
(via workflow configuration). Both configurations use the same Docker
image to ensure consistency.

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for
you](https://github.com/insightsengineering/teal/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: m7pr <133694481+m7pr@users.noreply.github.com>
@insightsengineering insightsengineering deleted a comment from Copilot AI Dec 9, 2025
m7pr added a commit that referenced this pull request Dec 9, 2025
When GitHub Copilot Coding Agent is run, it is run in GitHub Actions
environment.
This yaml file, specify the setup that will be used during the execution
of the job.

Coding Agent will work in the same docker conatiner as is used for
CI/CD.
It also verifies that R is installed and presents R session, before it
starts any job.

This way, we allow coding agent to use R and we use the same environment
as in our testing scenarios during CI/CD

Fixes
- insightsengineering/coredev-tasks#678

Partner to 
- #1628

Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Comment thread .devcontainer/devcontainer.json Outdated
@llrs-roche

llrs-roche commented Dec 12, 2025

Copy link
Copy Markdown
Contributor

When running this locally I got stuck at:

  • Launch Docker Desktop, or be sure Docker is running on your machine

I got prompted to install docker on WSL as I don't have Docker Desktop on my computer and saw this error:

image

Just to give some feedback (I am able to use the web based approach fine)

@m7pr

m7pr commented Dec 12, 2025

Copy link
Copy Markdown
Collaborator Author

@llrs-roche would you be able to try it with a public open docker container?
instead of our can you use rocker/r-ver ? so that we can understand if this might be an authorization issue.

does docker ps work in your terminal as well?

@donyunardi

Copy link
Copy Markdown
Contributor

Dev Containers extension needs to be installed first. Need to add this to the instruction.

I also can't get past this:

image

I confirmed my Docker Desktop is running.

Also, just to add, I believe internally we're moving away from Docker and prefer Podman? @llrs-roche can you confirm?
If so, we should align our process with our internal workflow.

@m7pr

m7pr commented Dec 15, 2025

Copy link
Copy Markdown
Collaborator Author

@llrs-roche @donyunardi are you logged to our GitHub Container Registry where the container is hosted?

docker login registry.rocde.roche.com

Let me know if you can run it if you login first.

@donyunardi Docker Desktop in this case is only used to verify that container is running, but it's not used by the setup/instruction.

@averissimo

averissimo commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

This works out of box for me. I already had the image pulled before.

  • Operating system: Ubuntu 25.10
  • VS Code: 1.105.1 and 1.107.0
  • Docker version 24.0.5, build ced0996

devcontainer extension in vs code was already installed

image

Comment thread .github/copilot-setup-steps.yml Outdated
Comment thread .devcontainer/devcontainer.json
@llrs-roche

Copy link
Copy Markdown
Contributor

I had to remove previous credentials on WSL for VS code to use the Linux docker process to set up the .devcontainer.

I can pull from it but I cannot commit.
The R version I got was 4.5.0, just to confirm that this is what's expected

image

@m7pr

m7pr commented Dec 15, 2025

Copy link
Copy Markdown
Collaborator Author

@llrs-roche you can not commit or you cannot push?

Changes made in the workspace should be visible outside the container and for sure you can commit and push outside the container. So if git config does not work from the inside of the container, use outside configuration and commit and push outside of the container.

@osenan

osenan commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

Hi @m7pr
The container worked fine, both in my machine (Ubuntu 22.10) and on Github Codespaces. Good work!!
image

In my case, on Codespaces I had to stop the container like this:
image
I could not find the command to stop in VS Code command pallete

@llrs-roche

Copy link
Copy Markdown
Contributor

@m7pr I cannot commit inside the container as it doesn't reuse the key to sign it, as I cannot commit I haven't pushed (I haven't tested pushing changes committed outside the devcontainer) but I guess it will work.
I just wanted to share my experience, as I expected to keep working as I do now on VS code/Positron where the signing key is picked up and in contrast to git pull that picks my credentials even inside the .devcontainer. I'll see if I can fix this

@m7pr

m7pr commented Dec 16, 2025

Copy link
Copy Markdown
Collaborator Author

@llrs-roche I have the same that I can pull and commit, but something crashes during push. But I can push from the terminal, that is outside the container.

@m7pr

m7pr commented Dec 16, 2025

Copy link
Copy Markdown
Collaborator Author

@osenan locally you first close Remote Connection, and then you can stop docker container locally trhough Docker Desktop or by using terminal.

@m7pr

m7pr commented Dec 16, 2025

Copy link
Copy Markdown
Collaborator Author

@donyunardi @chizapoth looking for your feedback as well. Just wondering if you were able to run it locally and in codespaces.
Other team members were able to use devcontainer. I am planning to merge this in this repository and also provide the file in other teal related repositories

m7pr added 2 commits December 17, 2025 16:36
Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Comment thread .devcontainer/devcontainer.json
Comment thread .devcontainer/devcontainer.json
Comment thread .devcontainer/devcontainer.json
Comment thread .devcontainer/devcontainer.json
@m7pr

m7pr commented Dec 22, 2025

Copy link
Copy Markdown
Collaborator Author

Hey, added

python, installed pre-commit

image image

Also I rebuild container locally to see that we added drawio and air-formatter extensions

image

drawio

image

air-formatter

image

radian

#1628 (comment)

image

@m7pr m7pr merged commit 4e87bb7 into main Dec 23, 2025
25 checks passed
@m7pr m7pr deleted the devcontainer branch December 23, 2025 10:02
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants