Skip to content

Commit

Permalink
Merge pull request #1 from Sage-Bionetworks/ecs_setting
Browse files Browse the repository at this point in the history
add docker image and specify environment variables
  • Loading branch information
danlu1 authored Apr 4, 2023
2 parents 0a4f578 + 48638e7 commit a771ca6
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 3 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/Release_Docker_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help

name: Create and publish a Docker image

on:
push:
branches:
- 'master'
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_PATH: ghcr.io/${{ github.repository }}

jobs:
tagging:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}

build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

- name: Log in to the Container registry
uses: docker/[email protected]
if: github.event_name == 'push'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.IMAGE_PATH }}

- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags}}
labels: ${{ steps.meta.outputs.labels }}
7 changes: 7 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM sagebionetworks/shiny-base:release-1.0
# This is the expected application installation folder
WORKDIR /srv/shiny-server/app
COPY --chown=shiny ./ ./

# Set up Python and install the Synapse Python client
RUN Rscript -e "install.packages('reticulate', repos='http://cran.rstudio.com/', verbose=FALSE)"
RUN Rscript -e "library(reticulate); install_miniconda(); py_discover_config(); py_install(c('synapseclient', 'pandas'), pip = TRUE, pip_ignore_installed=TRUE)"

# alternative to using renv
#RUN Rscript -e "install.packages(c('shinydashboard','tidyverse','readxl','gt','gtsummary','survival','survminer','rsconnect','janitor','rjson'), repos='http://cran.rstudio.com/', verbose=FALSE)"

# By default the log level is TRACE. We bump up one level to DEBUG to make the logs a bit less verbose
ENV SHINY_LOG_LEVEL=DEBUG

# set up r packages via renv. Use binary lib matching the shiny-base ubuntu version
# to speed up installatioon.
RUN Rscript -e 'renv::restore(repos="https://packagemanager.rstudio.com/all/__linux__/jammy/latest"); renv::install("./")'

# running that script, to pass a configuration env var to Shiny
RUN chmod +x dccmonitor_startup.sh
CMD ["./dccmonitor_startup.sh"]
10 changes: 9 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ app_url <- NULL
claims_param <- NULL
authorization_url <- NULL

if (interactive()) {
# testing url
options(shiny.port = 8100)
app_url <- "http://127.0.0.1:8100"
} else {
app_url <- Sys.getenv("APP_REDIRECT_URL")
}

.onLoad <- function(libname, pkgname) { # nolint
synapse <<- reticulate::import("synapseclient", delay_load = TRUE)
if (!interactive()) {
setup_global_oauth_vars(
app_url = get_golem_config("app_url"),
app_url = Sys.getenv("app_url"),
client_name = Sys.getenv("client_name"),
client_id = Sys.getenv("client_id"),
client_secret = Sys.getenv("client_secret")
Expand Down
2 changes: 1 addition & 1 deletion app.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# To deploy, run: rsconnect::deployApp()
# Or use the blue button on top of this file

Sys.setenv(R_CONFIG_ACTIVE = "default", # Replace "default" with your config
Sys.setenv(R_CONFIG_ACTIVE = Sys.getenv("R_CONFIG_ACTIVE"), # Replace "default" with your config
R_CONFIG_FILE = "inst/config.yml")
pkgload::load_all()
options("golem.app.prod" = TRUE)
Expand Down
8 changes: 8 additions & 0 deletions dccmonitor_startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/bash

# Pass environment variable to Shiny
echo "" >> .Renviron
echo APP_REDIRECT_URL=$APP_REDIRECT_URL >> .Renviron

# Now run the base start-up script
./startup.sh
54 changes: 53 additions & 1 deletion inst/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ amp-ad:
- "specimenID"

pec:
app_url: "https://shinypro.synapse.org/users/kmontgomery/dccmonitor/"
#app_url: "https://shinypro.synapse.org/users/danlu/dccmonitor-pec/"
samples_table: "syn22175287"
annotations_table: "syn20981788"
annotations_storage: "syn21763155"
Expand Down Expand Up @@ -174,3 +174,55 @@ pec:
- "libraryPrep"
- "libraryPreparationMethod"
- "runType"

1kD:
#app_url: "https://shinypro.synapse.org/users/danlu/dccmonitor_1kD/"
samples_table: "syn27817789"
annotations_table: "syn27806892"
annotations_storage: "syn27605404"
annotations_link: "https://www.synapse.org/#!Synapse:syn27817580"
annotation_keys:
- "age"
- "primaryDiagnosis"
consortium_fileview: "syn27646655"
teams:
- "3433360"
templates:
manifest_template: "syn27832372"
individual_templates:
human: "syn29358381"
biospecimen_templates:
human: "syn29358373"
assay_templates:
species_list:
- "human"
complete_columns:
manifest:
- "path"
- "parent"
- "fileFormat"
- "program"
- "project"
- "study"
- "resourceType"
individual:
- "program"
- "project"
- "study"
- "individualID"
- "householdID"
- "person"
- "sex"
- "noOfChildren"
- "noOfAdults"
- "spokenLanguage"
biospecimen:
- "program"
- "project"
- "study"
- "person"
- "individualID"
- "specimenID"
- "specimenType"
- "samplingAge"
- "samplingAgeUnits"

0 comments on commit a771ca6

Please sign in to comment.