Skip to content

Commit

Permalink
Merge pull request #1 from almahmoud/devel
Browse files Browse the repository at this point in the history
Add shiny build workflow
  • Loading branch information
LiNk-NY authored Jul 30, 2024
2 parents 5760229 + 82e1562 commit 7185cce
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/scripts/galaxy-wrapper-template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<tool id="interactivetool_biocshiny_{{{ID}}}" tool_type="interactive" name="{{{NAME}}}" version="0.1">
<description>{{{NAME}}} BiocShiny App</description>
<requirements>
<container type="docker">{{{CONTAINER}}}</container>
</requirements>
<entry_points>
<entry_point name="{{{ID}}}" requires_domain="True">
<port>3838</port>
</entry_point>
</entry_points>
<environment_variables>
<environment_variable name="HISTORY_ID">$__history_id__</environment_variable>
<environment_variable name="REMOTE_HOST">$__galaxy_url__</environment_variable>
<environment_variable name="GALAXY_URL">$__galaxy_url__</environment_variable>
<environment_variable name="API_KEY" inject="api_key" />
</environment_variables>
<command detect_errors="aggressive">/init</command>
<inputs>
</inputs>
<outputs>
</outputs>
<tests>
</tests>
<help>
This is an auto-generated wrapper for a BiocShiny application. See source and report issues at {{{SOURCE}}}.
</help>
</tool>
62 changes: 62 additions & 0 deletions .github/workflows/build_container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build shiny Docker image and generate Galaxy wrapper
on:
workflow_dispatch: {}
push: {}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Extract metadata for container image
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value={{branch}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64

- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push container image to ghcr
uses: docker/build-push-action@v4
with:
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64

- name: Set variables
id: vars
run: |
echo "container=${{ steps.meta.outputs.tags }}" >> $GITHUB_OUTPUT
echo "source=https://github.com/${{github.repository}}" >> $GITHUB_OUTPUT
NAME="$(echo '${{github.repository}}' | awk -F'/' '{print $2}')"
echo "name=$NAME" >> $GITHUB_OUTPUT
echo "id=$(echo $NAME | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Generate wrapper
run: |
cp .github/scripts/galaxy-wrapper-template.xml galaxy-wrapper.xml
sed -i 's#{{{CONTAINER}}}#${{steps.vars.outputs.container}}#g' galaxy-wrapper.xml
sed -i 's#{{{SOURCE}}}#${{steps.vars.outputs.source}}#g' galaxy-wrapper.xml
sed -i 's#{{{NAME}}}#${{steps.vars.outputs.name}}#g' galaxy-wrapper.xml
sed -i 's#{{{ID}}}#${{steps.vars.outputs.id}}#g' galaxy-wrapper.xml
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config user.name github-actions
git config user.email [email protected]
git add galaxy-wrapper.xml
git commit -m "Update Galaxy Wrapper $(TZ=EST date '+%Y-%m-%d_%H-%M')"
git push
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM ghcr.io/bioconductor/shiny:devel as build

RUN chown -R shiny /usr/local/lib/R/site-library && chown -R shiny /usr/local/lib/R/library && rm -rf /srv/shiny-server/sample-apps && curl -o /srv/shiny-server/index.html https://gist.githubusercontent.com/almahmoud/58261d03bfb342274f2e642c4b2ebc4d/raw/4e0271990bce57ae091f622db47b15f8fd89fa29/index.html && mkdir -p /srv/shiny-server/biocshiny && sed -i '/^run_as shiny;/a app_init_timeout 300;\napp_idle_timeout 300;' /etc/shiny-server/shiny-server.conf

COPY --chown=shiny:shiny . /tmp/repo/

USER shiny

RUN cd /tmp/repo && Rscript -e "options(repos = c(CRAN = 'https://cran.r-project.org')); BiocManager::install(ask=FALSE)" && Rscript -e "options(repos = c(CRAN = 'https://cran.r-project.org')); devtools::install('.', dependencies=TRUE, build_vignettes=TRUE, repos = BiocManager::repositories())" && rm -rf /tmp/repo

COPY --chown=shiny:shiny app.R /srv/shiny-server/biocshiny/app.R

USER root

0 comments on commit 7185cce

Please sign in to comment.