- Notifications
You must be signed in to change notification settings - Fork1
License
Unknown, MIT licenses found
Licenses found
VincentGuyader/shiny2docker
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
shiny2docker is an R package designed to streamline the process ofcontainerizing Shiny applications using Docker. By automating thegeneration of essential Docker files and managing R dependencies withrenv,shiny2docker simplifies the deployment of Shiny apps, ensuringreproducibility and consistency across different environments.
Automated Dockerfile Generation:
Quickly generate Dockerfiles tailored for Shiny applications. The mainfunction,shiny2docker(), creates a Dockerfile using arenv.lockfile to capture your R package dependencies.Dependency Management:
Utilizerenvto manage and restore R package dependencies. If alockfile does not exist,shiny2docker()will automatically createone for production using theattachment::create_renv_for_prodfunction.Customizability:
Theshiny2docker()function returns adockerfiler object thatcan be further manipulated usingdockerfiler’s methods beforewriting it to a file. This enables advanced users to customize theDockerfile to better suit their needs. Seedockerfiler for moredetails.GitLab CI Integration:
With theset_gitlab_ci()function, you can easily configure yourGitLab CI pipeline. This function copies a pre-configuredgitlab-ci.ymlfile from the package into your project directory. Theprovided CI configuration is designed to build your Docker image andpush the created image to the GitLab container registry, therebystreamlining continuous integration and deployment workflows.GitHub Actions Integration:
With theset_github_action()function, you can quickly set up aGitHub Actions pipeline. This function copies a pre-configureddocker-build.ymlfile from the package into the.github/workflows/directory of your project. The provided CI configuration is designedto build your Docker image and push the created image to the GitHubContainer Registry, facilitating automated builds and deployments onGitHub.
You can install the production version from CRAN with :
install.packages("shiny2docker")You can install the development version ofshiny2docker fromGitHub with:
# install.packages("pak")pak::pak("VincentGuyader/shiny2docker")
Use theshiny2docker() function to automatically generate a Dockerfilebased on your application’s dependencies.
library(shiny2docker)# Generate Dockerfile in the current directoryshiny2docker(path=".")# Generate Dockerfile with a specific renv.lock and output pathshiny2docker(path="path/to/shiny/app",lockfile="path/to/shiny/app/renv.lock",output="path/to/shiny/app/Dockerfile")# Further manipulate the Dockerfile object before writing to diskdocker_obj<- shiny2docker()docker_obj$ENV("MY_ENV_VAR","value")docker_obj$write("Dockerfile")
Theset_gitlab_ci() function allows you to quickly set up a GitLab CIpipeline that will build your Docker image and push it to the GitLabcontainer registry.
library(shiny2docker)# Copy the .gitlab-ci.yml file to the current directoryset_gitlab_ci()# Specify runner tagsset_gitlab_ci(tags= c("shiny_build","prod"))
The newset_github_action() function allows you to quickly set up aGitHub Actions pipeline that will build your Docker image and push it tothe GitHub Container Registry.
library(shiny2docker)# Copy the docker-build.yml file to the .github/workflows/ directoryset_github_action(path=".")
Once thedocker-build.yml file is in place, you can integrate it withGitHub Actions to automate the Docker image build and deploymentprocess.
Prepare Your Shiny Application:
Ensure that your Shiny app is located in a folder with the necessaryfiles (e.g.,app.Rorui.Randserver.R).Generate the Dockerfile:
Runshiny2docker()to create the Dockerfile (and a.dockerignorefile) in your project directory. This Dockerfile will includeinstructions to install system dependencies, R packages, and launchthe Shiny app.Set Up Continuous Integration (Optional):
- If you use GitLab, run
set_gitlab_ci()to copy thepre-configured GitLab CI file into your project. This CIconfiguration will handle the Docker image build and deployment toGitLab’s container registry. - If you use GitHub, run
set_github_action(path = ".")to copy thepre-configured GitHub Actions file into your project. This CIconfiguration will build your Docker image and push it to theGitHub Container Registry.
- If you use GitLab, run
Deploy Your Application:
Use Docker to build and run your image, or integrate with yourchosen CI/CD service for automated deployments.
This project is licensed under the terms of the MIT license.
About
Resources
License
Unknown, MIT licenses found
Licenses found
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.