Skip to content

Commit

Permalink
feat: update docker
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbrig committed Sep 11, 2024
1 parent 0855ce8 commit 66a93d6
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 15 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
46 changes: 41 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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")'
Expand All @@ -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()"

Check warning on line 56 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
29 changes: 19 additions & 10 deletions dev/app_deploy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit 66a93d6

Please sign in to comment.