Skip to content

Instantly share code, notes, and snippets.

@nturaga
Created July 27, 2023 17:08
Show Gist options
  • Save nturaga/9a97e387947505856db670287faec58b to your computer and use it in GitHub Desktop.
Save nturaga/9a97e387947505856db670287faec58b to your computer and use it in GitHub Desktop.

How to locally run the docker image

Build a new docker image

docker build -t us.gcr.io/tl-jvu4eyij9cslnrj0msep/trreports:0.0.3

Test the docker image locally

flags -it let you work on the docker image interactively

flags --entrypoint lets you overwrite the Rscript inside the Dockerfile.

docker run -it --entrypoint bash us.gcr.io/tl-jvu4eyij9cslnrj0msep/trreports:0.0.3

Within R

> source('try_docker.R', max = Inf, echo = TRUE)

Go into the /inst/ and check the logs and HTMLS

Push to Google Container Registry

docker push us.gcr.io/tl-jvu4eyij9cslnrj0msep/trreports:0.0.3

How to test on Kubernetes

gcloud container clusters 
	get-credentials 
	gke-services --region us-central1 
	--project tl-jvu4eyij9cslnrj0msep

Run your kube cron job on the cluster

kubectl apply -f config.yaml

Delete the cron job IF it doesn't work

kubectl delete cronjob.batch/trreports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment