Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslan-forostianov committed Mar 1, 2024
1 parent a5c8e19 commit 0647b2d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Stage 1: Build the application
FROM maven:3.9.6-amazoncorretto-21 as builder

# Set the working directory in the Maven image
WORKDIR /app

# Copy the java source files and the pom.xml file into the image
COPY src ./src
COPY pom.xml .

# Build the application
RUN mvn clean package

FROM python:3.11

# Install any needed packages specified in requirements.txt
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Install Perl. Some scripts are written in perl
RUN apt-get update && apt-get install -y perl

COPY scripts/ scripts/
RUN chmod -R a+x /scripts/

# Set the working directory in the container
WORKDIR /scripts/

ENV PORTAL_HOME=/

COPY --from=builder /app/core-*.jar /
# Set environment variables for Java version and installation paths
ENV JAVA_VERSION 21
ENV JAVA_HOME /usr/java/openjre-$JAVA_VERSION

# Install necessary packages for adding repositories over HTTPS
RUN apt-get update && \
apt-get install -y --no-install-recommends apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common && \
rm -rf /var/lib/apt/lists/*

# Download and install OpenJRE 21
# Note: The exact URL might change based on the latest available version, so replace it with the correct URL for JRE 21
RUN mkdir -p "$JAVA_HOME" && \
wget -O jdk21.tar.gz "https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz" && \
tar xvf jdk21.tar.gz --strip-components=1 -C "$JAVA_HOME" && \
rm jdk21.tar.gz

# Add java to PATH
ENV PATH $JAVA_HOME/bin:$PATH

# This file is empty. It has to be overriden by bind mounting the actual application.properties
RUN touch /application.properties
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,16 @@ The script will search for `core-*.jar` in the root of the project:
```bash
python scripts/importer/metaImport.py -s tests/test_data/study_es_0 -p tests/test_data/api_json_unit_tests -o
```

## Running in docker

Build docker image with:
```bash
docker build -t cbioportal-core .
```

Example of how to start the loading:
```bash
docker run -it -v $(pwd)/data/:/data/ -v $(pwd)/application.properties:/application.properties cbioportal-core python importer/metaImport.py -s /data/study_es_0 -p /data/api_json -o
```

0 comments on commit 0647b2d

Please sign in to comment.