Skip to content

Commit cf905a3

Browse files
author
adrian-knauer
committed
add dockerfile to build snap-egine plus microwave-toolbox
1 parent 3214e05 commit cf905a3

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

kpler-docker/Dockerfile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Start with a base image that includes Maven and Java 21
2+
FROM maven:3.9.6-eclipse-temurin-21
3+
4+
# Prevent interactive prompts during package installation
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Install additional necessary packages
8+
RUN apt-get update && apt-get install -y \
9+
libxrender1 \
10+
libxtst6 \
11+
libxi6 \
12+
libgl1-mesa-glx \
13+
libgtk2.0-0 \
14+
libdbus-glib-1-2 \
15+
libhdf5-dev \
16+
libjhdf5-java \
17+
&& apt-get clean \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
# Set environment variables for Java to find libjhdf5.so
21+
ENV LD_LIBRARY_PATH=/usr/lib/jni:$LD_LIBRARY_PATH
22+
ENV JAVA_LIBRARY_PATH=/usr/lib/jni
23+
24+
# Create directory for SNAP source code
25+
WORKDIR /opt/snap-src
26+
27+
# 1) clone snap-engine only
28+
RUN git clone https://github.com/senbox-org/snap-engine.git
29+
30+
# 2) copy **this repo’s** microwave-toolbox source in place of the public one
31+
COPY . /opt/snap-src/microwave-toolbox
32+
33+
# Build the SNAP Engine
34+
WORKDIR /opt/snap-src/snap-engine
35+
RUN mvn -q -B clean install -DskipTests
36+
37+
# Build the Microwave Toolbox
38+
WORKDIR /opt/snap-src/microwave-toolbox
39+
RUN mvn -q -B clean install -DskipTests
40+
41+
# Set environment variables for SNAP
42+
ENV SNAP_HOME=/opt/snap-src/snap-engine
43+
ENV SNAP_RUNTIME_CLASSPATH=/opt/snap-src/snap-engine/snap-runtime/target/snap-runtime.jar
44+
45+
# Find all JAR files and add them to the classpath
46+
RUN find /opt/snap-src/snap-engine -name "*.jar" | grep -v "^\." | grep -v "/src/" | \
47+
grep -v "/target/classes/" | grep -v "/target/test-classes/" > /opt/snap-src/snap-classpath.txt
48+
49+
# Set up environment for running GPT
50+
RUN echo '#!/bin/bash' > /usr/local/bin/gpt && \
51+
echo 'CLASSPATH=""' >> /usr/local/bin/gpt && \
52+
echo 'for JAR in $(cat /opt/snap-src/snap-classpath.txt); do' >> /usr/local/bin/gpt && \
53+
echo ' CLASSPATH="$CLASSPATH:$JAR"' >> /usr/local/bin/gpt && \
54+
echo 'done' >> /usr/local/bin/gpt && \
55+
echo 'for JAR in $(find /opt/snap-src/microwave-toolbox -name "*.jar" | grep -v "^\." | grep -v "/src/" | grep -v "/target/classes/" | grep -v "/target/test-classes/"); do' \
56+
>> /usr/local/bin/gpt && \
57+
echo ' CLASSPATH="$CLASSPATH:$JAR"' >> /usr/local/bin/gpt && \
58+
echo 'done' >> /usr/local/bin/gpt && \
59+
echo 'java -Xmx10G -XX:+UseG1GC -XX:+UseStringDeduplication -XX:MaxGCPauseMillis=200 -cp $CLASSPATH org.esa.snap.core.gpf.main.GPT "$@"' \
60+
>> /usr/local/bin/gpt && \
61+
chmod +x /usr/local/bin/gpt
62+
63+
# Add information to the profile
64+
RUN echo 'export SNAP_HOME=/opt/snap-src/snap-engine' >> /root/.bashrc && \
65+
echo 'export PATH=$SNAP_HOME/bin:$PATH' >> /root/.bashrc
66+
67+
# Define working directory for when container is running
68+
WORKDIR /data
69+
70+
CMD ["/bin/bash"]

0 commit comments

Comments
 (0)