From 3a84d714f5711f17a844d393710a3f8e989c705e Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:11:47 -0500 Subject: [PATCH 01/12] Update workflow name for dev-dashboard --- .github/workflows/docker-image-dev.yml | 41 ++++++++++++++++++++++++++ 05_DASHBOARD/Dockerfile-dev | 8 +++++ 05_DASHBOARD/deploy-dev.R | 15 ++++++++++ 3 files changed, 64 insertions(+) create mode 100644 .github/workflows/docker-image-dev.yml create mode 100644 05_DASHBOARD/Dockerfile-dev create mode 100644 05_DASHBOARD/deploy-dev.R diff --git a/.github/workflows/docker-image-dev.yml b/.github/workflows/docker-image-dev.yml new file mode 100644 index 0000000..56819a3 --- /dev/null +++ b/.github/workflows/docker-image-dev.yml @@ -0,0 +1,41 @@ +name: Build & Publish Dashboard-dev + +on: + push: + branches: + - hotfix/** # Matches any branch with prefix 'hotfix/' + - release/** # Matches any branch with prefix 'release/' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: gtmnerr + password: dckr_pat__hEdxbRrtLePYXseurTdnZ7da6M # CHANGE THIS TO BE A SECRET ON GITHUB ### + + # Build and push the Docker image to dockerhub + - name: Build and push docker image + uses: docker/build-push-action@v2 + with: + context: . + file: ./05_DASHBOARD/Dockerfile + push: true + tags: gtmnerr/dashboard-dev:latest + + # run the docker image to publish to shinyapps.io + - name: Run docker image + # CHANGE ALL VARIABLES TO BE SECRETS ON GITHUB ### + run: > + docker run -e SHINY_ACC_NAME=gtmnerr -e TOKEN=C45D396CDEDC0F87E0415BDDCB10D264 -e SECRET=amOf/66XsI1PtjFXGhEmWaBcuIzlhY6WLBirWL2y gtmnerr/dashboard-dev:latest \ No newline at end of file diff --git a/05_DASHBOARD/Dockerfile-dev b/05_DASHBOARD/Dockerfile-dev new file mode 100644 index 0000000..ffad918 --- /dev/null +++ b/05_DASHBOARD/Dockerfile-dev @@ -0,0 +1,8 @@ +FROM rocker/shiny:4.3.2 +RUN install2.r rsconnect shiny tidyverse bslib leaflet sf +WORKDIR /usr/src/dashboard-development +# Copy the 'app' directory contents into the container at /usr/src/app +COPY ./03_Data_for_app /usr/src/dashboard-development/ +COPY ./04_Tests /usr/src/dashboard-development/ +COPY ./05_DASHBOARD /usr/src/dashboard-development/ +CMD Rscript /usr/src/dashboard-development/05_DASHBOARD/deploy-dev.R diff --git a/05_DASHBOARD/deploy-dev.R b/05_DASHBOARD/deploy-dev.R new file mode 100644 index 0000000..2c7660b --- /dev/null +++ b/05_DASHBOARD/deploy-dev.R @@ -0,0 +1,15 @@ +# Load the rsconnect package +library(rsconnect) + +# Authenticate +rsconnect::setAccountInfo( + name = Sys.getenv("SHINY_ACC_NAME"), + token = Sys.getenv("TOKEN"), + secret = Sys.getenv("SECRET")) + +# Deploy +rsconnect::deployApp( + appDir = "./05_DASHBOARD", + appFiles = "app.R", + appName = "Dashboard-dev", + forceUpdate = TRUE) From 8d4cc1222323ae0a5aebc733b8cc73344a7e8058 Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:12:44 -0500 Subject: [PATCH 02/12] Test push workflow in GHA --- .github/workflows/docker-image-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image-dev.yml b/.github/workflows/docker-image-dev.yml index 56819a3..d4f003c 100644 --- a/.github/workflows/docker-image-dev.yml +++ b/.github/workflows/docker-image-dev.yml @@ -22,7 +22,7 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v1 with: - username: gtmnerr + username: gtmnerr # CHANGE THIS TO BE A SECRET ON GITHUB ### password: dckr_pat__hEdxbRrtLePYXseurTdnZ7da6M # CHANGE THIS TO BE A SECRET ON GITHUB ### # Build and push the Docker image to dockerhub From 7aa800ec32a43f48400fd7cf6d58df4f2723b47e Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:18:38 -0500 Subject: [PATCH 03/12] fixed dev dashboard dockerfile reference --- .github/workflows/docker-image-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image-dev.yml b/.github/workflows/docker-image-dev.yml index d4f003c..a58442d 100644 --- a/.github/workflows/docker-image-dev.yml +++ b/.github/workflows/docker-image-dev.yml @@ -30,7 +30,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - file: ./05_DASHBOARD/Dockerfile + file: ./05_DASHBOARD/Dockerfile-dev push: true tags: gtmnerr/dashboard-dev:latest From f7bd60e9ddcec8f05818cbf8ebb1ac47ae2c1d5d Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:30:59 -0500 Subject: [PATCH 04/12] test push trigger --- 05_DASHBOARD/Dockerfile-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/05_DASHBOARD/Dockerfile-dev b/05_DASHBOARD/Dockerfile-dev index ffad918..c13cbb9 100644 --- a/05_DASHBOARD/Dockerfile-dev +++ b/05_DASHBOARD/Dockerfile-dev @@ -1,7 +1,7 @@ FROM rocker/shiny:4.3.2 RUN install2.r rsconnect shiny tidyverse bslib leaflet sf WORKDIR /usr/src/dashboard-development -# Copy the 'app' directory contents into the container at /usr/src/app +# Copy the 'app' directory contents into the container at /usr/src/app COPY ./03_Data_for_app /usr/src/dashboard-development/ COPY ./04_Tests /usr/src/dashboard-development/ COPY ./05_DASHBOARD /usr/src/dashboard-development/ From 80f7db43c8b4a95ae83f5edf7d3c2c059788e0c2 Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:40:43 -0500 Subject: [PATCH 05/12] ensure dockerfile is run from correct branch --- .github/workflows/docker-image-dev.yml | 2 ++ .github/workflows/docker-image.yml | 2 ++ 05_DASHBOARD/Dockerfile | 4 ++++ 05_DASHBOARD/Dockerfile-dev | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/.github/workflows/docker-image-dev.yml b/.github/workflows/docker-image-dev.yml index a58442d..e74f001 100644 --- a/.github/workflows/docker-image-dev.yml +++ b/.github/workflows/docker-image-dev.yml @@ -33,6 +33,8 @@ jobs: file: ./05_DASHBOARD/Dockerfile-dev push: true tags: gtmnerr/dashboard-dev:latest + build-args: | + BRANCH_NAME=${{ github.ref_name }} # run the docker image to publish to shinyapps.io - name: Run docker image diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 40c3f70..aff769f 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -32,6 +32,8 @@ jobs: file: ./05_DASHBOARD/Dockerfile push: true tags: gtmnerr/dashboard:latest + build-args: | + BRANCH_NAME=${{ github.ref_name }} # run the docker image to publish to shinyapps.io - name: Run docker image diff --git a/05_DASHBOARD/Dockerfile b/05_DASHBOARD/Dockerfile index a43a76d..8eb9952 100644 --- a/05_DASHBOARD/Dockerfile +++ b/05_DASHBOARD/Dockerfile @@ -1,4 +1,8 @@ FROM rocker/shiny:4.3.2 +# Define BRANCH_NAME as an argument +ARG BRANCH_NAME +# You can use the ARG value as an environment variable if needed +ENV BRANCH_NAME=${BRANCH_NAME} RUN install2.r rsconnect shiny tidyverse bslib leaflet sf WORKDIR /usr/src/dashboard-development # Copy the 'app' directory contents into the container at /usr/src/app diff --git a/05_DASHBOARD/Dockerfile-dev b/05_DASHBOARD/Dockerfile-dev index c13cbb9..ba0fce5 100644 --- a/05_DASHBOARD/Dockerfile-dev +++ b/05_DASHBOARD/Dockerfile-dev @@ -1,4 +1,8 @@ FROM rocker/shiny:4.3.2 +# Define BRANCH_NAME as an argument +ARG BRANCH_NAME +# You can use the ARG value as an environment variable if needed +ENV BRANCH_NAME=${BRANCH_NAME} RUN install2.r rsconnect shiny tidyverse bslib leaflet sf WORKDIR /usr/src/dashboard-development # Copy the 'app' directory contents into the container at /usr/src/app From 2495d41fc3c6de7014414ea08b208fbbb826b870 Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:51:11 -0500 Subject: [PATCH 06/12] make all docker build to not use cache --- .github/workflows/docker-image-dev.yml | 1 + .github/workflows/docker-image.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/docker-image-dev.yml b/.github/workflows/docker-image-dev.yml index e74f001..1423518 100644 --- a/.github/workflows/docker-image-dev.yml +++ b/.github/workflows/docker-image-dev.yml @@ -33,6 +33,7 @@ jobs: file: ./05_DASHBOARD/Dockerfile-dev push: true tags: gtmnerr/dashboard-dev:latest + no-cache: true build-args: | BRANCH_NAME=${{ github.ref_name }} diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index aff769f..5d67ee1 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -32,6 +32,7 @@ jobs: file: ./05_DASHBOARD/Dockerfile push: true tags: gtmnerr/dashboard:latest + no-cache: true build-args: | BRANCH_NAME=${{ github.ref_name }} From 1e961229304177faa0d2c757e5a53a49c5b4765f Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:56:18 -0500 Subject: [PATCH 07/12] add copy directly of dev deploy file. --- 05_DASHBOARD/Dockerfile-dev | 1 + 1 file changed, 1 insertion(+) diff --git a/05_DASHBOARD/Dockerfile-dev b/05_DASHBOARD/Dockerfile-dev index ba0fce5..e4f7118 100644 --- a/05_DASHBOARD/Dockerfile-dev +++ b/05_DASHBOARD/Dockerfile-dev @@ -3,6 +3,7 @@ FROM rocker/shiny:4.3.2 ARG BRANCH_NAME # You can use the ARG value as an environment variable if needed ENV BRANCH_NAME=${BRANCH_NAME} +COPY ./05_DASHBOARD/deploy-dev.R /usr/src/dashboard-development/ RUN install2.r rsconnect shiny tidyverse bslib leaflet sf WORKDIR /usr/src/dashboard-development # Copy the 'app' directory contents into the container at /usr/src/app From 329b28da3cc2b24cb169ae9e49d82d5113cd4d46 Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:03:06 -0500 Subject: [PATCH 08/12] try copy of full path --- 05_DASHBOARD/Dockerfile | 4 +++- 05_DASHBOARD/Dockerfile-dev | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/05_DASHBOARD/Dockerfile b/05_DASHBOARD/Dockerfile index 8eb9952..a6484dc 100644 --- a/05_DASHBOARD/Dockerfile +++ b/05_DASHBOARD/Dockerfile @@ -6,5 +6,7 @@ ENV BRANCH_NAME=${BRANCH_NAME} RUN install2.r rsconnect shiny tidyverse bslib leaflet sf WORKDIR /usr/src/dashboard-development # Copy the 'app' directory contents into the container at /usr/src/app -COPY ./ /usr/src/dashboard-development +COPY ./03_Data_for_app /usr/src/dashboard-development/ +COPY ./04_Tests /usr/src/dashboard-development/ +COPY ./05_DASHBOARD /usr/src/dashboard-development/ CMD Rscript /usr/src/dashboard-development/05_DASHBOARD/deploy.R diff --git a/05_DASHBOARD/Dockerfile-dev b/05_DASHBOARD/Dockerfile-dev index e4f7118..208ec3c 100644 --- a/05_DASHBOARD/Dockerfile-dev +++ b/05_DASHBOARD/Dockerfile-dev @@ -3,11 +3,11 @@ FROM rocker/shiny:4.3.2 ARG BRANCH_NAME # You can use the ARG value as an environment variable if needed ENV BRANCH_NAME=${BRANCH_NAME} -COPY ./05_DASHBOARD/deploy-dev.R /usr/src/dashboard-development/ RUN install2.r rsconnect shiny tidyverse bslib leaflet sf WORKDIR /usr/src/dashboard-development # Copy the 'app' directory contents into the container at /usr/src/app COPY ./03_Data_for_app /usr/src/dashboard-development/ COPY ./04_Tests /usr/src/dashboard-development/ COPY ./05_DASHBOARD /usr/src/dashboard-development/ +COPY ./05_DASHBOARD/deploy-dev.R /usr/src/dashboard-development/05_DASHBOARD/ CMD Rscript /usr/src/dashboard-development/05_DASHBOARD/deploy-dev.R From 304a3b1a8d40f250bad4f54f1c7e481aa56e9b4e Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:09:08 -0500 Subject: [PATCH 09/12] add force update and remove direct copy --- 05_DASHBOARD/Dockerfile-dev | 1 - 05_DASHBOARD/deploy.R | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/05_DASHBOARD/Dockerfile-dev b/05_DASHBOARD/Dockerfile-dev index 208ec3c..ba0fce5 100644 --- a/05_DASHBOARD/Dockerfile-dev +++ b/05_DASHBOARD/Dockerfile-dev @@ -9,5 +9,4 @@ WORKDIR /usr/src/dashboard-development COPY ./03_Data_for_app /usr/src/dashboard-development/ COPY ./04_Tests /usr/src/dashboard-development/ COPY ./05_DASHBOARD /usr/src/dashboard-development/ -COPY ./05_DASHBOARD/deploy-dev.R /usr/src/dashboard-development/05_DASHBOARD/ CMD Rscript /usr/src/dashboard-development/05_DASHBOARD/deploy-dev.R diff --git a/05_DASHBOARD/deploy.R b/05_DASHBOARD/deploy.R index b3b92a5..d04a254 100644 --- a/05_DASHBOARD/deploy.R +++ b/05_DASHBOARD/deploy.R @@ -11,4 +11,5 @@ rsconnect::setAccountInfo( rsconnect::deployApp( appDir = "./05_DASHBOARD", appFiles = "app.R", - appName = "Dashboard") + appName = "Dashboard", + forceUpdate = TRUE) From 480870e90ff222ca3ab3e5ee38891d8815c498c7 Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:21:24 -0500 Subject: [PATCH 10/12] retry and see if files are in the docker image --- .github/workflows/docker-image-dev.yml | 3 +++ 05_DASHBOARD/Dockerfile | 2 +- 05_DASHBOARD/Dockerfile-dev | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image-dev.yml b/.github/workflows/docker-image-dev.yml index 1423518..342221e 100644 --- a/.github/workflows/docker-image-dev.yml +++ b/.github/workflows/docker-image-dev.yml @@ -36,6 +36,9 @@ jobs: no-cache: true build-args: | BRANCH_NAME=${{ github.ref_name }} + + - name: List contents of the app directory + run: docker run --rm gtmnerr/dashboard-dev:latest ls /usr/src/dashboard-development/05_DASHBOARD/ # run the docker image to publish to shinyapps.io - name: Run docker image diff --git a/05_DASHBOARD/Dockerfile b/05_DASHBOARD/Dockerfile index a6484dc..a777927 100644 --- a/05_DASHBOARD/Dockerfile +++ b/05_DASHBOARD/Dockerfile @@ -5,7 +5,7 @@ ARG BRANCH_NAME ENV BRANCH_NAME=${BRANCH_NAME} RUN install2.r rsconnect shiny tidyverse bslib leaflet sf WORKDIR /usr/src/dashboard-development -# Copy the 'app' directory contents into the container at /usr/src/app +# Copy the 'app' directory contents into the container COPY ./03_Data_for_app /usr/src/dashboard-development/ COPY ./04_Tests /usr/src/dashboard-development/ COPY ./05_DASHBOARD /usr/src/dashboard-development/ diff --git a/05_DASHBOARD/Dockerfile-dev b/05_DASHBOARD/Dockerfile-dev index ba0fce5..af58987 100644 --- a/05_DASHBOARD/Dockerfile-dev +++ b/05_DASHBOARD/Dockerfile-dev @@ -5,7 +5,7 @@ ARG BRANCH_NAME ENV BRANCH_NAME=${BRANCH_NAME} RUN install2.r rsconnect shiny tidyverse bslib leaflet sf WORKDIR /usr/src/dashboard-development -# Copy the 'app' directory contents into the container at /usr/src/app +# Copy the 'app' directory contents into the container COPY ./03_Data_for_app /usr/src/dashboard-development/ COPY ./04_Tests /usr/src/dashboard-development/ COPY ./05_DASHBOARD /usr/src/dashboard-development/ From 984fef84ced20c81daf611cc6dd1200a0a8e6813 Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:37:12 -0500 Subject: [PATCH 11/12] see contents of parent directory --- .github/workflows/docker-image-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image-dev.yml b/.github/workflows/docker-image-dev.yml index 342221e..e9e7096 100644 --- a/.github/workflows/docker-image-dev.yml +++ b/.github/workflows/docker-image-dev.yml @@ -38,7 +38,7 @@ jobs: BRANCH_NAME=${{ github.ref_name }} - name: List contents of the app directory - run: docker run --rm gtmnerr/dashboard-dev:latest ls /usr/src/dashboard-development/05_DASHBOARD/ + run: docker run --rm gtmnerr/dashboard-dev:latest ls /usr/src/dashboard-development/ # run the docker image to publish to shinyapps.io - name: Run docker image From 185d9b1efb2b20067f7ca7667a10ffba84ae5d59 Mon Sep 17 00:00:00 2001 From: Chris <53177842+ChristopherMarais@users.noreply.github.com> Date: Tue, 6 Feb 2024 17:40:47 -0500 Subject: [PATCH 12/12] change copy command --- 05_DASHBOARD/Dockerfile | 6 +++--- 05_DASHBOARD/Dockerfile-dev | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/05_DASHBOARD/Dockerfile b/05_DASHBOARD/Dockerfile index a777927..e9769d1 100644 --- a/05_DASHBOARD/Dockerfile +++ b/05_DASHBOARD/Dockerfile @@ -6,7 +6,7 @@ ENV BRANCH_NAME=${BRANCH_NAME} RUN install2.r rsconnect shiny tidyverse bslib leaflet sf WORKDIR /usr/src/dashboard-development # Copy the 'app' directory contents into the container -COPY ./03_Data_for_app /usr/src/dashboard-development/ -COPY ./04_Tests /usr/src/dashboard-development/ -COPY ./05_DASHBOARD /usr/src/dashboard-development/ +COPY ./03_Data_for_app /usr/src/dashboard-development/03_Data_for_app/ +COPY ./04_Tests /usr/src/dashboard-development/04_Tests/ +COPY ./05_DASHBOARD /usr/src/dashboard-development/05_DASHBOARD/ CMD Rscript /usr/src/dashboard-development/05_DASHBOARD/deploy.R diff --git a/05_DASHBOARD/Dockerfile-dev b/05_DASHBOARD/Dockerfile-dev index af58987..1a6f996 100644 --- a/05_DASHBOARD/Dockerfile-dev +++ b/05_DASHBOARD/Dockerfile-dev @@ -6,7 +6,7 @@ ENV BRANCH_NAME=${BRANCH_NAME} RUN install2.r rsconnect shiny tidyverse bslib leaflet sf WORKDIR /usr/src/dashboard-development # Copy the 'app' directory contents into the container -COPY ./03_Data_for_app /usr/src/dashboard-development/ -COPY ./04_Tests /usr/src/dashboard-development/ -COPY ./05_DASHBOARD /usr/src/dashboard-development/ +COPY ./03_Data_for_app /usr/src/dashboard-development/03_Data_for_app/ +COPY ./04_Tests /usr/src/dashboard-development/04_Tests/ +COPY ./05_DASHBOARD /usr/src/dashboard-development/05_DASHBOARD/ CMD Rscript /usr/src/dashboard-development/05_DASHBOARD/deploy-dev.R