### Complete CI/CD Workflow Example Source: https://context7.com/vincentguyader/shiny2docker/llms.txt This example demonstrates the full workflow: generating a Dockerfile, customizing it, and setting up GitHub Actions for automated builds and pushes to ghcr.io. ```R library(shiny2docker) project_path <- "/path/to/shiny/app" # Step 1: Generate Dockerfile docker_obj <- shiny2docker(path = project_path) # Step 2: Customize if needed docker_obj$add_after(cmd = "ENV R_CONFIG_ACTIVE=production", after = 1) docker_obj$write(file.path(project_path, "Dockerfile")) # Step 3: Set up GitHub Actions for automated builds set_github_action(path = project_path) # The generated workflow will: # - Trigger on push to main/master branches # - Build Docker image using the Dockerfile # - Push to ghcr.io/{owner}/{repo}:latest # - Push to ghcr.io/{owner}/{repo}:{commit-sha} ``` -------------------------------- ### Install shiny2docker from GitHub Source: https://github.com/vincentguyader/shiny2docker/blob/main/README.md Install the development version of the shiny2docker package from GitHub using pak. ```r # install.packages("pak") pak::pak("VincentGuyader/shiny2docker") ``` -------------------------------- ### Install shiny2docker from CRAN Source: https://github.com/vincentguyader/shiny2docker/blob/main/README.md Install the production version of the shiny2docker package from CRAN. ```r install.packages("shiny2docker") ``` -------------------------------- ### Customize and Write Dockerfile Source: https://github.com/vincentguyader/shiny2docker/blob/main/README.md Generate a Dockerfile object, customize it by adding environment variables, and then write it to a file. ```r # Further manipulate the Dockerfile object before writing to disk docker_obj <- shiny2docker() docker_obj$ENV("MY_ENV_VAR", "value") docker_obj$write("Dockerfile") ``` -------------------------------- ### Configure GitLab CI Source: https://github.com/vincentguyader/shiny2docker/blob/main/README.md Copy a pre-configured .gitlab-ci.yml file to the current directory to set up a GitLab CI pipeline for building and pushing Docker images. ```r library(shiny2docker) # Copy the .gitlab-ci.yml file to the current directory set_gitlab_ci() ``` -------------------------------- ### Configure GitHub Actions Source: https://github.com/vincentguyader/shiny2docker/blob/main/README.md Copy a pre-configured docker-build.yml file to the .github/workflows/ directory to set up a GitHub Actions pipeline for building and pushing Docker images. ```r library(shiny2docker) # Copy the docker-build.yml file to the .github/workflows/ directory set_github_action(path = ".") ``` -------------------------------- ### set_github_action() - Configure GitHub Actions Source: https://context7.com/vincentguyader/shiny2docker/llms.txt Copies a pre-configured `docker-build.yml` workflow file to the `.github/workflows/` directory, setting up a GitHub Actions pipeline for building Docker images on push to main/master branches and pushing them to the GitHub Container Registry (ghcr.io). ```APIDOC ## set_github_action() ### Description Configures a GitHub Actions pipeline for Docker builds by copying a pre-configured `docker-build.yml` workflow file to the `.github/workflows/` directory. The workflow automatically builds Docker images on push to `main` or `master` branches and pushes them to the GitHub Container Registry (ghcr.io). ### Method `set_github_action` ### Parameters #### Path Parameters - **path** (string) - Required - The root directory of the GitHub repository where the workflow file will be placed. ### Request Example ```r library(shiny2docker) # Basic usage set_github_action(path = ".") # Set up in a specific project directory set_github_action(path = "/home/user/my-shiny-app") ``` ### Response #### Success Response (boolean) - **TRUE** - Indicates that the workflow file was successfully created. #### Response Example ``` TRUE ``` ``` -------------------------------- ### Configure GitLab CI with Runner Tags Source: https://github.com/vincentguyader/shiny2docker/blob/main/README.md Copy a pre-configured .gitlab-ci.yml file to the current directory, specifying custom runner tags for the CI pipeline. ```r # Specify runner tags set_gitlab_ci(tags = c("shiny_build", "prod")) ``` -------------------------------- ### Configure GitLab CI Pipelines Source: https://context7.com/vincentguyader/shiny2docker/llms.txt Use set_gitlab_ci to copy a pre-configured .gitlab-ci.yml file to your project, enabling automated Docker builds via Kaniko. ```r library(shiny2docker) # Basic usage: Copy .gitlab-ci.yml to the current directory set_gitlab_ci(path = ".") # Copy to a specific project directory set_gitlab_ci(path = "/home/user/my-shiny-app") # Specify GitLab runner tags for job execution set_gitlab_ci(path = ".", tags = c("docker", "linux")) # Use multiple tags for specific runner selection set_gitlab_ci(path = ".", tags = c("shiny_build", "prod", "large-runner")) # Copy to a temporary directory for testing result <- set_gitlab_ci(path = tempdir()) if (result) { message("GitLab CI configuration successfully created!") } # The generated .gitlab-ci.yml will contain: # stages: # - build # build_shiny_image: # stage: build # tags: # Added when tags parameter is provided # - docker # - linux # image: # name: gcr.io/kaniko-project/executor:debug # script: # - /kaniko/executor --destination "${CI_REGISTRY_IMAGE}:latest" # only: # - main # - master ``` -------------------------------- ### set_gitlab_ci() - Configure GitLab CI Source: https://context7.com/vincentguyader/shiny2docker/llms.txt Copies a pre-configured `.gitlab-ci.yml` file to your project directory, setting up a GitLab CI pipeline for automated Docker image builds using Kaniko and pushing to the GitLab Container Registry. Supports specifying runner tags. ```APIDOC ## set_gitlab_ci() ### Description Configures a GitLab CI pipeline for Docker builds by copying a pre-configured `.gitlab-ci.yml` file to the specified path. This CI configuration uses Kaniko for building Docker images and pushing them to the GitLab Container Registry. It supports specifying GitLab runner tags. ### Method `set_gitlab_ci` ### Parameters #### Path Parameters - **path** (string) - Required - The directory where the `.gitlab-ci.yml` file will be copied. - **tags** (string array) - Optional - A character vector of GitLab runner tags to be used for the CI job. ### Request Example ```r library(shiny2docker) # Basic usage set_gitlab_ci(path = ".") # With custom tags set_gitlab_ci(path = "/home/user/my-shiny-app", tags = c("docker", "linux")) ``` ### Response #### Success Response (boolean) - **TRUE** - Indicates that the `.gitlab-ci.yml` file was successfully copied. #### Response Example ``` TRUE ``` ``` -------------------------------- ### Configure GitHub Actions Pipelines Source: https://context7.com/vincentguyader/shiny2docker/llms.txt Use set_github_action to copy a pre-configured docker-build.yml workflow file to the .github/workflows/ directory for automated builds. ```r library(shiny2docker) # Basic usage: Set up GitHub Actions in the current directory set_github_action(path = ".") # Set up in a specific project directory set_github_action(path = "/home/user/my-shiny-app") ``` -------------------------------- ### Generate Dockerfile for Shiny App Source: https://github.com/vincentguyader/shiny2docker/blob/main/README.md Generate a Dockerfile for a Shiny application in the current directory. If a lockfile does not exist, it will be created. ```r library(shiny2docker) # Generate Dockerfile in the current directory shiny2docker(path = ".") ``` -------------------------------- ### Create GitHub Actions Workflow Source: https://context7.com/vincentguyader/shiny2docker/llms.txt Use this function to create a GitHub Actions workflow for automated Docker builds. It requires a temporary directory path for testing. ```R result <- set_github_action(path = tempdir()) if (result) { message("GitHub Actions workflow successfully created!") # File created at: {tempdir()}/.github/workflows/docker-build.yml } ``` -------------------------------- ### Generate Dockerfile with Specific Paths Source: https://github.com/vincentguyader/shiny2docker/blob/main/README.md Generate a Dockerfile for a Shiny application specifying the application path, lockfile path, and output Dockerfile path. ```r # Generate Dockerfile with a specific renv.lock and output path shiny2docker(path = "path/to/shiny/app", lockfile = "path/to/shiny/app/renv.lock", output = "path/to/shiny/app/Dockerfile") ``` -------------------------------- ### shiny2docker() - Generate Dockerfile Source: https://context7.com/vincentguyader/shiny2docker/llms.txt The main function to generate a Dockerfile for a Shiny application. It automates the creation of `renv.lock`, `.dockerignore`, and the Dockerfile itself, managing system dependencies, R packages, and app launch configurations. It returns a `dockerfiler` object for further customization. ```APIDOC ## shiny2docker() ### Description Generates a Dockerfile for a Shiny application, automating dependency management with `renv`, creating `.dockerignore` files, and configuring system dependencies and R package installations. Returns a `dockerfiler` object for further customization. ### Method `shiny2docker` ### Parameters #### Path Parameters - **path** (string) - Required - The directory containing the Shiny application. - **lockfile** (string) - Optional - Path to the `renv.lock` file. If not provided, it will be generated. - **output** (string) - Optional - The path where the Dockerfile will be written. Defaults to `Dockerfile` in the `path` directory. - **FROM** (string) - Optional - Specifies the base Docker image to use. Defaults to a rocker/shiny image. - **AS** (string) - Optional - Specifies a name for the build stage when using multi-stage builds. Defaults to `NULL`. - **sysreqs** (boolean) - Optional - Whether to detect and include system requirements. Defaults to `TRUE`. - **repos** (string array) - Optional - A character vector of R package repositories to use. - **expand** (boolean) - Optional - Whether to expand R package dependencies. Defaults to `TRUE`. - **extra_sysreqs** (string array) - Optional - A character vector of additional system dependencies to install. - **use_pak** (boolean) - Optional - Whether to use `pak` for faster dependency installation. Defaults to `FALSE`. - **user** (string) - Optional - The user to run the Shiny application as inside the container. Defaults to `shiny`. - **dependencies** (any) - Optional - Specifies R package dependencies. Defaults to `NA`. - **sysreqs_platform** (string) - Optional - The platform for which to detect system requirements (e.g., "ubuntu-22.04"). Defaults to the system's default. - **folder_to_exclude** (string array) - Optional - A character vector of folders to exclude from the Docker build context. ### Request Example ```r library(shiny2docker) # Basic usage shiny2docker(path = ".") # With custom options shiny2docker( path = "/srv/myapp", lockfile = "/srv/myapp/renv.lock", output = "/srv/myapp/Dockerfile", FROM = "rocker/geospatial", extra_sysreqs = c("libpoppler-cpp-dev"), use_pak = TRUE ) # Customizing the dockerfiler object docker_obj <- shiny2docker(path = ".") docker_obj$add_after(cmd = "ENV MY_VAR=my_value", after = 1) docker_obj$write("Dockerfile") ``` ### Response #### Success Response (dockerfiler object) - **dockerfiler object** - A `dockerfiler` object that can be further manipulated before writing to disk. #### Response Example (A `dockerfiler` object is returned, not a direct JSON response. Customizations are applied via its methods.) ``` -------------------------------- ### Generate Dockerfiles with shiny2docker Source: https://context7.com/vincentguyader/shiny2docker/llms.txt Use the shiny2docker function to create Dockerfiles, manage dependencies, and customize build configurations. The function returns a dockerfiler object for further programmatic modification. ```r library(shiny2docker) # Basic usage: Generate Dockerfile in the current directory shiny2docker(path = ".") # Generate Dockerfile with custom paths shiny2docker( path = "path/to/shiny/app", lockfile = "path/to/shiny/app/renv.lock", output = "path/to/shiny/app/Dockerfile" ) # Use a different base image and disable system requirements detection shiny2docker( path = ".", FROM = "rocker/shiny:4.3.0", sysreqs = FALSE ) # Enable pak for faster dependency installation shiny2docker( path = ".", use_pak = TRUE, repos = c(CRAN = "https://cloud.r-project.org/") ) # Add extra system dependencies and specify platform shiny2docker( path = ".", extra_sysreqs = c("libcurl4-openssl-dev", "libssl-dev"), sysreqs_platform = "ubuntu-22.04" ) # Customize the Dockerfile using the returned dockerfiler object docker_obj <- shiny2docker(path = ".") # Add environment variables after the FROM instruction docker_obj$add_after(cmd = "ENV ARROW_WITH_S3=1", after = 1) docker_obj$add_after(cmd = "ENV ARROW_S3=ON", after = 2) # Add a custom label docker_obj$add_after(cmd = "LABEL maintainer='team@example.com'", after = 1) # Write the customized Dockerfile docker_obj$write("Dockerfile") # Full example with all options docker_obj <- shiny2docker( path = "/srv/myapp", lockfile = "/srv/myapp/renv.lock", output = "/srv/myapp/Dockerfile", FROM = "rocker/geospatial", AS = NULL, sysreqs = TRUE, repos = c(CRAN = "https://cran.rstudio.com/"), expand = FALSE, extra_sysreqs = c("libpoppler-cpp-dev"), use_pak = FALSE, user = "shiny", dependencies = NA, sysreqs_platform = "ubuntu", folder_to_exclude = c("renv", "tests") ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.