[Bioc-devel] Add dockerhub push to github repository

Nuno Agostinho nunod@n|e|@go@t|nho @end|ng |rom gm@||@com
Thu Jun 3 12:57:35 CEST 2021


Hey Alan,

> I would like to automatically create a new image and push to dockerhub with github actions when I push changes to the github repository. Does anyone have an example of this process in their repositories?


Well, I use GitHub actions to build a Docker image and push it to GitHub Container Registry, maybe this could help somehow: https://github.com/nuno-agostinho/psichomics/blob/master/.github/workflows/docker.yml <https://github.com/nuno-agostinho/psichomics/blob/master/.github/workflows/docker.yml>

I use GitHub releases to release a new package version and, every time I release a new version, a new Docker image is built (this image also gets automatically tagged with the latest tag). I also build Docker images every time I push changes to the dev branch.

Regarding DockerHub, I have DockerHub set up to automatically build Docker images every time I push to master (to create the latest tag) and dev branches in GitHub, as well as every time I create a new tag (which I do when creating new releases). I could put this in the GitHub actions, but I didn't bother yet.

> I would ideally like the tag of this dockerhub push to be the R package version (from the DESCRIPTION) to differentiate between images, is this possible?

I think you can run some bash script in your GitHub Actions based on your DESCRIPTION file. I would have to test but maybe something like:

    - name: Get R package version
      run: |
        version=$(grep Version DESCRIPTION | grep -o "[0-9.]\+")
        echo "packageVersion=${version}" >> $GITHUB_ENV
      shell:
        bash {0}

You can then access this variable in other steps via ${{ env.packageVersion }} like so:

    - name: Build and push
      uses: docker/build-push-action using v2
      with:
        push: true
        tags: ${{ github.repository }}:${{ env.packageVersion }}

> Is there a way to tell the Dockerfile to install the R package in the current repository?


To build the image, I use ADD . . to put the GitHub repository content in the Docker image and then install the package using remotes::install_local(), as you can see from my Dockerfile: https://github.com/nuno-agostinho/psichomics/blob/master/Dockerfile <https://github.com/nuno-agostinho/psichomics/blob/master/Dockerfile>

I hope I was clear and helpful. Please tell me if you need help with anything else! :)

Best,
Nuno Agostinho

> On 3 Jun 2021, at 07:52, Murphy, Alan E <a.murphy using imperial.ac.uk> wrote:
> 
> Hi all,
> 
> I'm working on developing an R package with the aim to eventually submit to Bioconductor. I would like to automatically create a new image and push to dockerhub with github actions when I push changes to the github repository. Does anyone have an example of this process in their repositories?
> 
> Two things to also consider, I would ideally like the tag of this dockerhub push to be the R package version (from the DESCRIPTION) to differentiate between images, is this possible? Secondly, I currently have the dockerfile created but, since my R package repository is private I have been building the R package and using the tar.gz file in the dockerfile to install the package (rather than using devtools::install_github()). Is there a way to tell the Dockerfile to install the R package in the current repository?
> 
> Kind regards,
> Alan.
> 
> Alan Murphy
> Bioinformatician
> Neurogenomics lab
> UK Dementia Research Institute
> Imperial College London
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> Bioc-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/bioc-devel


	[[alternative HTML version deleted]]



More information about the Bioc-devel mailing list