Skip to content

Commit

Permalink
ready to build image
Browse files Browse the repository at this point in the history
  • Loading branch information
spfeiffe committed Apr 3, 2024
1 parent edbd079 commit ea6677b
Show file tree
Hide file tree
Showing 16 changed files with 3,130 additions and 20 deletions.
1 change: 1 addition & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source("renv/activate.R")
88 changes: 88 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

on:
push:
branches:
- docker-container

jobs:
build-and-push-image:
runs-on: ubuntu-latest
outputs:
image_name: "${{ steps.meta.outputs.tags }}@${{ steps.build_push_action.outputs.digest }}"
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: build_push_action
uses: docker/build-push-action@v3
with:
context: .
push: true
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# scan:
# runs-on: ubuntu-latest
# needs: build-and-push-image
# steps:
# - uses: actions/checkout@v3
# - name: Scan image
# id: scan
# uses: anchore/[email protected]
# with:
# fail-build: false
# image: ${{needs.build-and-push-image.outputs.image_name}}
# - name: upload Anchore scan SARIF report
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: ${{ steps.scan.outputs.sarif }}

# deploy:
# runs-on: ubuntu-latest
# needs: scan
#
# steps:
# - uses: actions/checkout@v3
# env:
# CG_USERNAME: ${{ secrets.CG_USERNAME }}
# if: ${{ env.CG_USERNAME }}
# - name: Deploy to cloud.gov
# uses: cloud-gov/cg-cli-tools@main
# env:
# CG_USERNAME: ${{ secrets.CG_USERNAME }}
# if: ${{ env.CG_USERNAME }}
# with:
# cf_username: ${{ secrets.CG_USERNAME }}
# cf_password: ${{ secrets.CG_PASSWORD }}
# cf_org: ${{ secrets.CF_ORG }}
# cf_space: ${{ secrets.CF_SPACE }}
# command: cf delete Heat_CVD_UHI_Dashboard -f ; cf push -f manifest.yml
88 changes: 88 additions & 0 deletions .github/workflows/deploy.yml.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

on:
push:
branches:
- docker-container

jobs:
build-and-push-image:
runs-on: ubuntu-latest
outputs:
image_name: "${{ steps.meta.outputs.tags }}@${{ steps.build_push_action.outputs.digest }}"
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
id: build_push_action
uses: docker/build-push-action@v3
with:
context: .
push: true
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# scan:
# runs-on: ubuntu-latest
# needs: build-and-push-image
# steps:
# - uses: actions/checkout@v3
# - name: Scan image
# id: scan
# uses: anchore/[email protected]
# with:
# fail-build: false
# image: ${{needs.build-and-push-image.outputs.image_name}}
# - name: upload Anchore scan SARIF report
# uses: github/codeql-action/upload-sarif@v2
# with:
# sarif_file: ${{ steps.scan.outputs.sarif }}

# deploy:
# runs-on: ubuntu-latest
# needs: scan
#
# steps:
# - uses: actions/checkout@v3
# env:
# CG_USERNAME: ${{ secrets.CG_USERNAME }}
# if: ${{ env.CG_USERNAME }}
# - name: Deploy to cloud.gov
# uses: cloud-gov/cg-cli-tools@main
# env:
# CG_USERNAME: ${{ secrets.CG_USERNAME }}
# if: ${{ env.CG_USERNAME }}
# with:
# cf_username: ${{ secrets.CG_USERNAME }}
# cf_password: ${{ secrets.CG_PASSWORD }}
# cf_org: ${{ secrets.CF_ORG }}
# cf_space: ${{ secrets.CF_SPACE }}
# command: cf delete Heat_CVD_UHI_Dashboard -f ; cf push -f manifest.yml
3 changes: 3 additions & 0 deletions .grype.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ignore:
- package:
location: "/opt/shiny-server/node_modules/**"
47 changes: 47 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# The image is based off of the rocker base image, which you can learn about here:
# https://rocker-project.org/
# The image is based off of ubuntu, but then runs a few scripts to install R and R shiny
FROM rocker/shiny:latest

# I added this label, though it doesn't do anything
LABEL name=CBCS

# I reset the ubuntu package mirror to the Oregon State open source lab, because at some point while I was working on this
# the official ubuntu package mirror went offline, but this can probably be removed
RUN sed -i -e 's/http:\/\/archive\.ubuntu\.com\/ubuntu\//http:\/\/ubuntu\.osuosl\.org\/ubuntu/' /etc/apt/sources.list

# This part is the part that installs the system packages, usually needed for use in compiling some R package.
# I just added packages to this list as I got errors
RUN apt-get update && apt-get install -y \
libssl-dev \
libxml2-dev \
libgit2-dev \
default-jdk \
r-cran-rjava \
r-base-dev dh-r automake \
libharfbuzz-dev libfribidi-dev \
libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev \
libgdal-dev \
libudunits2-dev \
cmake \
&& apt-get clean

# This sets the main path in the docker image to /app, which is a standard practice.
WORKDIR /app

# This is part copies in the renv dependency list
# The reason this is copied in seperately is for caching. Docker if it sees the dependencies haven't changed doesn't have to spend
# the time re-compiling everything
COPY renv.lock renv.lock
RUN mkdir -p renv
COPY .Rprofile .Rprofile
COPY renv/activate.R renv/activate.R
COPY renv/settings.dcf renv/settings.dcf
RUN Rscript -e 'install.packages("renv")'
RUN Rscript -e 'renv::restore()'

# This part copies in the rest of the project
COPY . /app

# This sets what is run when the docker image is run
CMD ["Rscript", "run.R"]
47 changes: 47 additions & 0 deletions Dockerfile.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# The image is based off of the rocker base image, which you can learn about here:
# https://rocker-project.org/
# The image is based off of ubuntu, but then runs a few scripts to install R and R shiny
FROM rocker/shiny:latest

# I added this label, though it doesn't do anything
LABEL name=MyPracticeApp1

# I reset the ubuntu package mirror to the Oregon State open source lab, because at some point while I was working on this
# the official ubuntu package mirror went offline, but this can probably be removed
RUN sed -i -e 's/http:\/\/archive\.ubuntu\.com\/ubuntu\//http:\/\/ubuntu\.osuosl\.org\/ubuntu/' /etc/apt/sources.list

# This part is the part that installs the system packages, usually needed for use in compiling some R package.
# I just added packages to this list as I got errors
RUN apt-get update && apt-get install -y \
libssl-dev \
libxml2-dev \
libgit2-dev \
default-jdk \
r-cran-rjava \
r-base-dev dh-r automake \
libharfbuzz-dev libfribidi-dev \
libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev \
libgdal-dev \
libudunits2-dev \
cmake \
&& apt-get clean

# This sets the main path in the docker image to /app, which is a standard practice.
WORKDIR /app

# This is part copies in the renv dependency list
# The reason this is copied in seperately is for caching. Docker if it sees the dependencies haven't changed doesn't have to spend
# the time re-compiling everything
COPY renv.lock renv.lock
RUN mkdir -p renv
COPY .Rprofile .Rprofile
COPY renv/activate.R renv/activate.R
COPY renv/settings.dcf renv/settings.dcf
RUN Rscript -e 'install.packages("renv")'
RUN Rscript -e 'renv::restore()'

# This part copies in the rest of the project
COPY . /app

# This sets what is run when the docker image is run
CMD ["Rscript", "run.R"]
1 change: 0 additions & 1 deletion Procfile

This file was deleted.

1 change: 0 additions & 1 deletion app.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ library(deSolve)
library(ggplot2)
library(reshape2)
library(scales)
library(shiny)
library(shinyBS)
library(shinythemes)

Expand Down
Loading

0 comments on commit ea6677b

Please sign in to comment.