diff --git a/.dockerignore b/.dockerignore index 10f86fd..f1baf5a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -5,6 +5,19 @@ manifest.json rsconnect/ .Rproj.user +docs/ +.github/ +.lintr +CHANGELOG.md +README.md +codecov.yml +config.yml +index.md +LICENSE +LICENSE.md +Makefile +NEWS.md +pkgdown/ # Ignore generated credentials from google-github-actions/auth gha-creds-*.json diff --git a/Dockerfile b/Dockerfile index 7f99c46..f352e0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,28 @@ -FROM rocker/r-ver:latest -RUN apt-get update && apt-get install -y && rm -rf /var/lib/apt/lists/* +FROM rocker/r-ver:latest AS base + +RUN apt-get update -y -qq && apt-get -y --no-install-recommends install \ + make \ + git \ + pandoc \ + pandoc-citeproc \ + zlib1g-dev \ + libcurl4-openssl-dev \ + libssl-dev \ + libxml2-dev \ + libicu-dev \ + libjpeg-dev \ + libjq-dev \ + libglpk-dev \ + && rm -rf /var/lib/apt/lists/* \ + && apt-get -y autoremove \ + && apt-get -y clean + RUN mkdir -p /usr/local/lib/R/etc/ /usr/lib/R/etc/ -RUN echo "options(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 + +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 + RUN R -e 'install.packages("remotes")' + RUN Rscript -e 'remotes::install_version("pkgload",upgrade="never", version = "1.3.4")' RUN Rscript -e 'remotes::install_version("knitr",upgrade="never", version = "1.47")' RUN Rscript -e 'remotes::install_version("shiny",upgrade="never", version = "1.8.1.1")' @@ -11,10 +31,26 @@ RUN Rscript -e 'remotes::install_version("testthat",upgrade="never", version = " RUN Rscript -e 'remotes::install_version("spelling",upgrade="never", version = "2.3.0")' RUN Rscript -e 'remotes::install_version("rmarkdown",upgrade="never", version = "2.27")' RUN Rscript -e 'remotes::install_version("golem",upgrade="never", version = "0.4.1")' + +# RUN R -e 'remotes::install_version("renv", version = "1.0.3")' +# COPY renv.lock.prod renv.lock +# RUN R -e 'renv::restore()' + +FROM base AS dev + +# COPY renv.lock.prod renv.lock +# RUN R -e 'options(renv.config.pak.enabled = FALSE); renv::restore()' +# COPY *.tar.gz /app.tar.gz +# RUN R -e 'remotes::install_local("/app.tar.gz",upgrade="never")' +# RUN rm /app.tar.gz + RUN mkdir /build_zone ADD . /build_zone WORKDIR /build_zone RUN R -e 'remotes::install_local(upgrade="never")' RUN rm -rf /build_zone -EXPOSE 5000 -CMD R -e "options('shiny.port'=5000,shiny.host='0.0.0.0');library(rshinycloudrun);rshinycloudrun::run_app()" + +EXPOSE 8080 +USER shiny + +CMD R -e "options('shiny.port'=8080,shiny.host='0.0.0.0');library(rshinycloudrun);rshinycloudrun::run_app()" diff --git a/dev/app_deploy.R b/dev/app_deploy.R index eaf0502..43bd7da 100644 --- a/dev/app_deploy.R +++ b/dev/app_deploy.R @@ -10,22 +10,31 @@ devtools::check() devtools::build() # Dockerfile -------------------------------------------------------------- -golem::add_dockerfile() +dockerfiler::dock_from_desc() # Deployment ------------------------------------------------------------- library(googleCloudRunner) options(cli.ignore_unknown_rstudio_theme = TRUE) -gcp_config <- config::get("gcp", file = "inst/config.yml") +gcp_config <- config::get("gcp", file = "inst/config/config.yml") + +# Sys.setenv( +# "GCE_DEFAULT_PROJECT_ID" = gcp_config$project_id, +# "GAR_CLIENT_JSON" = gcp_config$client_json, +# "GCE_AUTH_FILE" = gcp_config$auth_file, +# "GCS_DEFAULT_BUCKET" = gcp_config$bucket, +# "CR_REGION" = gcp_config$region, +# "CR_BUILD_EMAIL" = gcp_config$build_email +# ) + +golem::add_dockerfile_with_renv() + +cr_project_set(gcp_config$project_id) +cr_region_set(gcp_config$region) +cr_email_set(gcp_config$build_email) +cr_bucket_set(gcp_config$bucket) + -Sys.setenv( - "GCE_DEFAULT_PROJECT_ID" = gcp_config$project_id, - "GAR_CLIENT_JSON" = gcp_config$client_json, - "GCE_AUTH_FILE" = gcp_config$auth_file, - "GCS_DEFAULT_BUCKET" = gcp_config$bucket, - "CR_REGION" = gcp_config$region, - "CR_BUILD_EMAIL" = gcp_config$build_email -) googleCloudRunner::cr_deploy_docker( local = getwd(),