Skip to content

Commit 231271d

Browse files
authored
Merge pull request #10 from ExposuresProvider/generate-package-with-github-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.
2 parents fe7b5a6 + 2422ed5 commit 231271d

File tree

2 files changed

+82
-15
lines changed

2 files changed

+82
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# This GitHub Action generates and publishes a Docker image of this repository
2+
# to the GitHub Packages repository. It is triggered when a new package is released.
3+
#
4+
# Based on the NameRes release.yaml file at
5+
# https://github.com/TranslatorSRI/NameResolution/blob/a4f72e3c283dcb40a7280b55650dae63c5625e82/.github/workflows/release.yml
6+
7+
name: 'Publish Docker image to Github Packages'
8+
9+
on:
10+
release:
11+
types: [published]
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
16+
jobs:
17+
push_to_registry:
18+
name: Push Docker image to GitHub Packages tagged with "latest" and version number.
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check out the repo
22+
uses: actions/checkout@v3
23+
- name: Get the version
24+
id: get_version
25+
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
26+
- name: Extract metadata (tags, labels) for Docker
27+
id: meta
28+
uses: docker/metadata-action@v4
29+
with:
30+
images:
31+
ghcr.io/${{ github.repository }}
32+
- name: Login to ghcr
33+
uses: docker/login-action@v1
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Push to GitHub Packages
39+
uses: docker/build-push-action@v4
40+
with:
41+
context: .
42+
push: true
43+
tags: ${{ steps.meta.outputs.tags }}
44+
labels: ${{ steps.meta.outputs.labels }}
45+
build-args: BRANCH_NAME=${{ github.event.release.target_commitish }}

Dockerfile

+37-15
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,75 @@ ARG BGR=1.7
77
ARG CTD=0.3.0
88
ARG MAT=0.1
99

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

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

14-
RUN apt-get update \
15-
&& DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
23+
RUN apt-get update
24+
RUN DEBIAN_FRONTEND="noninteractive" apt-get upgrade -y --no-install-recommends
25+
RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
1626
software-properties-common \
1727
build-essential \
1828
openjdk-11-jdk-headless \
1929
git \
2030
make \
2131
curl \
2232
tar \
33+
vim \
2334
screen \
2435
rsync \
25-
locales \
26-
&& locale-gen "en_US.UTF-8"
36+
locales
37+
RUN locale-gen "en_US.UTF-8"
38+
39+
###### SCALA-CLI ######
40+
RUN curl -fLo scala-cli.deb https://github.com/Virtuslab/scala-cli/releases/latest/download/scala-cli-x86_64-pc-linux.deb \
41+
&& dpkg -i scala-cli.deb
42+
43+
### 3. Set up the $DATA and $TOOLS directory.
44+
RUN mkdir -p ${DATA}
45+
RUN mkdir -p ${TOOLS}
2746

47+
### 4. Set up a non-root user.
48+
RUN useradd --uid ${USERID} -m ${USERNAME}
49+
RUN chown ${USERNAME} ${DATA}
50+
RUN chown ${USERNAME} ${TOOLS}
51+
USER ${USERNAME}
2852

29-
### 3. Install custom tools
30-
WORKDIR /tools
53+
### 5. Install custom tools
54+
WORKDIR $TOOLS
3155

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

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

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

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

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

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

0 commit comments

Comments
 (0)