|
1 | 1 |
|
2 | 2 | <!-- README.md is generated from README.Rmd. Please edit that file -->
|
3 | 3 |
|
4 |
| -# shinydocker |
| 4 | +> \[!IMPORTANT\] |
| 5 | +> |
| 6 | +> This package is currently in the prototype/experimental stage. It is |
| 7 | +> not yet available on CRAN and may have bugs or limitations. |
| 8 | +
|
| 9 | +# shinydocker <img src="man/figures/shinydocker-animated-logo.svg" align="right" height="139" /> |
5 | 10 |
|
6 | 11 | <!-- badges: start -->
|
7 | 12 |
|
| 13 | +[](https://github.com/coatless-rpkg/shinydocker/actions/workflows/R-CMD-check.yaml) |
| 14 | + |
| 15 | + |
8 | 16 | <!-- badges: end -->
|
9 | 17 |
|
10 |
| -The goal of shinydocker is to … |
| 18 | +`shinydocker` is an R package that streamlines the process of |
| 19 | +containerizing Shiny applications, supporting both R and Python Shiny |
| 20 | +apps. |
11 | 21 |
|
12 | 22 | ## Installation
|
13 | 23 |
|
14 |
| -You can install the development version of shinydocker from |
15 |
| -[GitHub](https://github.com/) with: |
| 24 | +You can install the development version of `shinydocker` from GitHub |
| 25 | +with: |
16 | 26 |
|
17 | 27 | ``` r
|
18 |
| -# install.packages("pak") |
19 |
| -pak::pak("coatless-rpkg/shinydocker") |
| 28 | +# install.packages("remotes") |
| 29 | +remotes::install_github("coatless-rpkg/shinydocker") |
20 | 30 | ```
|
21 | 31 |
|
22 |
| -## Example |
| 32 | +You will also need to have Docker installed on your system. You can |
| 33 | +download Docker from the [official |
| 34 | +website](https://www.docker.com/products/docker-desktop). You do not |
| 35 | +need to log in to Docker to use `shinydocker`. |
| 36 | + |
| 37 | +## Using shinydocker |
| 38 | + |
| 39 | +The package provides a set of functions to automate the process, as well |
| 40 | +as options for advanced configuration. |
| 41 | + |
| 42 | +### Exporting a Shiny App to Docker |
| 43 | + |
| 44 | +The `export()` function allows you to convert a Shiny application into a |
| 45 | +docker containerized application. |
| 46 | + |
| 47 | +``` r |
| 48 | +# Automated export: configures, builds, and optionally runs the container |
| 49 | +export("path/to/your/shinyapp", run = TRUE) |
| 50 | +``` |
23 | 51 |
|
24 |
| -This is a basic example which shows you how to solve a common problem: |
| 52 | +For example, to convert the “Hello World” Shiny app from the `{shiny}` |
| 53 | +package into a standalone Electron app: |
| 54 | + |
| 55 | +``` r |
| 56 | +# Copy "Hello World" from `{shiny}` |
| 57 | +system.file("examples", "01_hello", package="shiny") |> |
| 58 | + fs::dir_copy("myapp", overwrite = TRUE) |
| 59 | + |
| 60 | +shinydocker::export("myapp", run = TRUE) |
| 61 | +``` |
| 62 | + |
| 63 | +### Manually Dockerizing a Shiny App |
25 | 64 |
|
26 | 65 | ``` r
|
27 | 66 | library(shinydocker)
|
28 |
| -## basic example code |
| 67 | + |
| 68 | +# Path to your Shiny app |
| 69 | +shiny_app_path <- "path/to/your/shinyapp" |
| 70 | + |
| 71 | +# Create Docker configuration for a Shiny app |
| 72 | +dockerize(shiny_app_path) |
| 73 | + |
| 74 | +# Build a Docker image |
| 75 | +build_image(shiny_app_path) |
| 76 | + |
| 77 | +# Run the container |
| 78 | +run_container(shiny_app_path) |
| 79 | +``` |
| 80 | + |
| 81 | +### Diagnostic Tools |
| 82 | + |
| 83 | +``` r |
| 84 | +# Check Docker environment |
| 85 | +sitrep_docker() |
| 86 | + |
| 87 | +# Analyze app containerization readiness |
| 88 | +sitrep_app_conversion("path/to/your/shinyapp") |
29 | 89 | ```
|
30 | 90 |
|
31 |
| -What is special about using `README.Rmd` instead of just `README.md`? |
32 |
| -You can include R chunks like so: |
| 91 | +## Advanced Configuration |
| 92 | + |
| 93 | +### Custom Dockerfile |
33 | 94 |
|
34 | 95 | ``` r
|
35 |
| -summary(cars) |
36 |
| -#> speed dist |
37 |
| -#> Min. : 4.0 Min. : 2.00 |
38 |
| -#> 1st Qu.:12.0 1st Qu.: 26.00 |
39 |
| -#> Median :15.0 Median : 36.00 |
40 |
| -#> Mean :15.4 Mean : 42.98 |
41 |
| -#> 3rd Qu.:19.0 3rd Qu.: 56.00 |
42 |
| -#> Max. :25.0 Max. :120.00 |
| 96 | +# Use a custom Dockerfile template |
| 97 | +dockerize("path/to/your/shinyapp", |
| 98 | + custom_dockerfile = "path/to/custom/Dockerfile") |
43 | 99 | ```
|
44 | 100 |
|
45 |
| -You’ll still need to render `README.Rmd` regularly, to keep `README.md` |
46 |
| -up-to-date. `devtools::build_readme()` is handy for this. |
| 101 | +### Environment Variables |
47 | 102 |
|
48 |
| -You can also embed plots, for example: |
| 103 | +``` r |
| 104 | +# Set environment variables during containerization |
| 105 | +dockerize("path/to/your/shinyapp", |
| 106 | + env_vars = c(API_KEY = "your-secret-key")) |
| 107 | +``` |
| 108 | + |
| 109 | +## Cleanup and Management |
| 110 | + |
| 111 | +``` r |
| 112 | +# Stop a specific container |
| 113 | +stop_containers("path/to/your/shinyapp") |
| 114 | + |
| 115 | +# Clean up Docker containers and images |
| 116 | +cleanup_containers(remove_images = TRUE) |
| 117 | +``` |
49 | 118 |
|
50 |
| -<img src="man/figures/README-pressure-1.png" width="100%" /> |
| 119 | +## License |
51 | 120 |
|
52 |
| -In that case, don’t forget to commit and push the resulting figure |
53 |
| -files, so they display on GitHub and CRAN. |
| 121 | +AGPL (\>= 3) |
0 commit comments