-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Run `golem::add_dockerfile_with_renv()` * Rename files * Clean up base Dockerfile * Clean up main Dockerfile * Remove dev dependencies from `renv.lock.prod` * Update deployment instructions * Update README; add overview and Deployment section
- Loading branch information
Showing
7 changed files
with
1,305 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ $run_dev.* | |
^\.github$ | ||
^\.lintr$ | ||
^\.renvignore$ | ||
^deploy$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM calypso_base:4.4.1 | ||
|
||
WORKDIR /app | ||
COPY renv.lock.prod renv.lock | ||
|
||
RUN R -e 'renv::restore()' | ||
|
||
COPY calypso_*.tar.gz /app.tar.gz | ||
RUN R -e 'remotes::install_local("/app.tar.gz", upgrade="never")' && \ | ||
rm /app.tar.gz | ||
|
||
EXPOSE 3838 | ||
CMD ["R", "-e", "options('shiny.port'=3838,shiny.host='0.0.0.0');library(calypso);calypso::run_app()"] | ||
|
||
# to build: docker build -t calypso . | ||
# to run: docker run -p 3838:3838 calypso |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM rocker/shiny-verse:4.4.1 | ||
SHELL ["/bin/bash", "-o", "pipefail", "-e", "-u", "-x", "-c"] | ||
|
||
RUN mkdir -p /usr/local/lib/R/etc/ /usr/lib/R/etc/ | ||
|
||
# Set R options | ||
RUN echo "options(renv.config.pak.enabled = FALSE, repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl', Ncpus = 4)" |\ | ||
tee /usr/local/lib/R/etc/Rprofile.site | \ | ||
tee /usr/lib/R/etc/Rprofile.site | ||
|
||
# Install renv | ||
RUN R -e 'install.packages("remotes")' && \ | ||
R -e 'remotes::install_version("renv", version = "1.0.7")' | ||
|
||
# Restore renv environment | ||
RUN mkdir /app | ||
WORKDIR /app | ||
COPY renv.lock.prod renv.lock | ||
RUN R -e 'renv::restore()' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Deploy | ||
|
||
## Build the package | ||
|
||
From the package root directory, run from `R`: | ||
|
||
```r | ||
pkgbuild::build(path = ".", dest_path = "deploy") | ||
``` | ||
|
||
## Create `renv.lock.prod` | ||
|
||
From the package root directory, run from `R`: | ||
|
||
```r | ||
renv::snapshot(project = ".", lockfile = "./deploy/renv.lock.prod", type = "explicit") | ||
``` | ||
|
||
## Build Docker images | ||
|
||
In the `deploy/` directory, run: | ||
|
||
```shell | ||
# Assuming R version 4.4.1 | ||
docker build -f Dockerfile.base --platform=linux/amd64 -t calypso_base:4.4.1 . | ||
docker build -f Dockerfile --platform=linux/amd64 -t calypso:latest . | ||
``` | ||
|
||
The `calypso_base` image acts as a cached image with most of the necessary dependencies installed, | ||
to speed up the build process of the `calypso` image. The base image is not intended to be run and | ||
is only expected to be rebuilt in case of major dependency changes. | ||
|
||
Note that the `calypso` image also includes a `renv::restore()` step, so any dependencies not present | ||
in the base image will still be installed. | ||
|
||
## Run Docker container | ||
|
||
```shell | ||
docker run -p 3838:3838 calypso:latest | ||
# then go to 127.0.0.1:80 | ||
``` |
Binary file not shown.
Oops, something went wrong.