Skip to content

Commit

Permalink
Merge pull request #10 from ExposuresProvider/generate-package-with-g…
Browse files Browse the repository at this point in the history
…ithub-action

This PR reorganizes the Dockerfile so that tools are in /tools and data is in /data, as well as an nru user (non-root user) that can be used to run this package. All of these options are configurable. It also adds a GitHub Action to automatically regenerate the Docker package whenever we make a new release.

Closes #9.
  • Loading branch information
gaurav authored Aug 15, 2024
2 parents fe7b5a6 + 2422ed5 commit 231271d
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 15 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/generate-docker-package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This GitHub Action generates and publishes a Docker image of this repository
# to the GitHub Packages repository. It is triggered when a new package is released.
#
# Based on the NameRes release.yaml file at
# https://github.com/TranslatorSRI/NameResolution/blob/a4f72e3c283dcb40a7280b55650dae63c5625e82/.github/workflows/release.yml

name: 'Publish Docker image to Github Packages'

on:
release:
types: [published]

env:
REGISTRY: ghcr.io

jobs:
push_to_registry:
name: Push Docker image to GitHub Packages tagged with "latest" and version number.
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images:
ghcr.io/${{ github.repository }}
- name: Login to ghcr
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push to GitHub Packages
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: BRANCH_NAME=${{ github.event.release.target_commitish }}
52 changes: 37 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,75 @@ ARG BGR=1.7
ARG CTD=0.3.0
ARG MAT=0.1

### 2. Get Java and all required system libraries
# Configuration options:
# - ${USERNAME} is the name of the non-root user to create.
ARG USERNAME=nru
# - ${USERID} is the UID of the non-root user.
ARG USERID=1001
# - ${DATA} is where the writeable data volume should be mounted.
ARG DATA=/data
# - ${TOOLS} is where the writeable tools volume should be mounted.
ARG TOOLS=/tools

### 2. Get Java and all required system libraries
ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8

RUN apt-get update \
&& DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
RUN apt-get update
RUN DEBIAN_FRONTEND="noninteractive" apt-get upgrade -y --no-install-recommends
RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
software-properties-common \
build-essential \
openjdk-11-jdk-headless \
git \
make \
curl \
tar \
vim \
screen \
rsync \
locales \
&& locale-gen "en_US.UTF-8"
locales
RUN locale-gen "en_US.UTF-8"

###### SCALA-CLI ######
RUN curl -fLo scala-cli.deb https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-linux.deb \
&& dpkg -i scala-cli.deb

### 3. Set up the $DATA and $TOOLS directory.
RUN mkdir -p ${DATA}
RUN mkdir -p ${TOOLS}

### 4. Set up a non-root user.
RUN useradd --uid ${USERID} -m ${USERNAME}
RUN chown ${USERNAME} ${DATA}
RUN chown ${USERNAME} ${TOOLS}
USER ${USERNAME}

### 3. Install custom tools
WORKDIR /tools
### 5. Install custom tools
WORKDIR $TOOLS

###### JENA ######
RUN curl -O -L http://archive.apache.org/dist/jena/binaries/apache-jena-$JENA.tar.gz \
&& tar -zxf apache-jena-$JENA.tar.gz
ENV PATH "/tools/apache-jena-$JENA/bin:$PATH"
ENV PATH "$TOOLS/apache-jena-$JENA/bin:$PATH"

###### BLAZEGRAPH-RUNNER ######
RUN curl -O -L https://github.com/balhoff/blazegraph-runner/releases/download/v$BGR/blazegraph-runner-$BGR.tgz \
&& tar -zxf blazegraph-runner-$BGR.tgz \
&& chmod +x /tools/blazegraph-runner-$BGR
ENV PATH "/tools/blazegraph-runner-$BGR/bin:$PATH"
ENV PATH "$TOOLS/blazegraph-runner-$BGR/bin:$PATH"

###### MATERIALIZER ######
RUN curl -O -L https://github.com/balhoff/materializer/releases/download/v$MAT/materializer-$MAT.tgz \
&& tar -zxf materializer-$MAT.tgz \
&& chmod +x /tools/materializer-$MAT
ENV PATH "/tools/materializer-$MAT/bin:$PATH"
ENV PATH "$TOOLS/materializer-$MAT/bin:$PATH"

###### CTD-TO-OWL ######
RUN curl -O -L https://github.com/balhoff/ctd-to-owl/releases/download/v$CTD/ctd-to-owl-$CTD.tgz \
&& tar -zxf ctd-to-owl-$CTD.tgz \
&& chmod +x /tools/ctd-to-owl-$CTD
ENV PATH "/tools/ctd-to-owl-$CTD/bin:$PATH"
ENV PATH "$TOOLS/ctd-to-owl-$CTD/bin:$PATH"

###### SCALA-CLI ######
RUN curl -fLo scala-cli.deb https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-linux.deb \
&& dpkg -i scala-cli.deb
### 6. Start in the $DATA directory.
WORKDIR $DATA

RUN useradd --system --uid 1001 -m cam

0 comments on commit 231271d

Please sign in to comment.