Skip to content

Commit

Permalink
build: use GitHub PAT to install R packages on GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
adamblake committed Jan 4, 2024
1 parent 33c0c17 commit e5f5eb9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ jobs:
context: ${{ inputs.image }}
platforms: linux/amd64
build-args: ${{ inputs.build-args }}
secrets: "github_token=${{ secrets.GITHUB_TOKEN }}"
tags: localhost:5000/${{ github.repository_owner }}/${{ inputs.image }}:amd64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/${{ inputs.image }}
cache-to: type=registry,ref=localhost:5000/${{ github.repository_owner }}/${{ inputs.image }}:buildcache-amd64,mode=max
Expand Down
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Contributing to this project

## Prerequisites

These are required system dependencies for this project:

- [Git](https://git-scm.com/)
- [GitHub CLI](https://cli.github.com/)
- [Docker](https://docs.docker.com/get-docker/)
- [GNU Make](https://www.gnu.org/software/make/)

## Setup

1. Fork/Clone this repository
2. Sign into GitHub CLI: `gh auth login`
3. Ensure `buildx` is enabled: `docker buildx ls`
4. Use `make` to get a list of available commands
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ DS_RUN_ARGS?=
export DOCKER_BUILDKIT:=1
# Activate experimental mode
export DOCKER_CLI_EXPERIMENTAL=enabled
# Load the GitHub Personal Access Token from the environment
export github_token:=$(shell gh auth token)

# Check if the local registry is running
LOCAL_REGISTRY_UP := $(shell docker ps --filter name=registry --format "{{.Names}}" | grep -q registry && echo true || echo false)
Expand Down Expand Up @@ -44,6 +46,7 @@ define build_image
@echo
docker buildx build $(COMMON_BUILD_ARGS) $(BUILD_ARGS) \
--platform $(1) \
--secret id=github_token \
--tag "$(LOCAL_REGISTRY)/$(DS_OWNER)/$(notdir $(2))" \
--push \
"./$(notdir $(2))"
Expand Down
3 changes: 2 additions & 1 deletion essentials-notebook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ RUN --mount=type=cache,target="${CONDA_DIR}/pkgs",uid=${NB_UID},sharing=locked \
# install all other R packages
ARG R_REQUIREMENTS
RUN --mount=type=bind,source="${R_REQUIREMENTS}",target=/tmp/requirements.r \
Rscript /tmp/requirements.r
--mount=type=secret,id=github_token,uid=${NB_UID} \
GITHUB_PAT=$(cat /run/secrets/github_token) Rscript /tmp/requirements.r


# pre-shared-libs
Expand Down
5 changes: 3 additions & 2 deletions r-notebook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ RUN --mount=type=cache,target=${CONDA_DIR}/pkgs,uid=${NB_UID},sharing=locked \

# install all other R packages
ARG R_REQUIREMENTS
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN --mount=type=bind,source="${R_REQUIREMENTS}",target=/tmp/requirements.r \
export CARGO_NET_GIT_FETCH_WITH_CLI=true \
&& Rscript /tmp/requirements.r
--mount=type=secret,id=github_token,uid=${NB_UID} \
GITHUB_PAT=$(cat /run/secrets/github_token) Rscript /tmp/requirements.r


# pre-shared-libs
Expand Down

0 comments on commit e5f5eb9

Please sign in to comment.