diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..41409940 --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index 3dbceb97..60433f9c 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,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 +``` +