Skip to content

Commit

Permalink
Install python on java docker image instead of otherwise
Browse files Browse the repository at this point in the history
python is more straightforward to install than java
  • Loading branch information
ruslan-forostianov committed Apr 1, 2024
1 parent 5c0d572 commit 3587a27
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Stage 1: Build the application
FROM maven:3-eclipse-temurin-21 as builder
FROM maven:3-eclipse-temurin-21 as jar_builder

# Set the working directory in the Maven image
WORKDIR /app
Expand All @@ -11,15 +10,29 @@ COPY pom.xml .
# Build the application
RUN mvn clean package -DskipTests

FROM python:3.11
FROM maven:3-eclipse-temurin-21

# download system dependencies first to take advantage of docker caching
RUN apt-get update; apt-get install -y --no-install-recommends \
build-essential \
default-mysql-client \
default-libmysqlclient-dev \
python3 \
python3-setuptools \
python3-dev \
python3-pip \
unzip \
perl \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install wheel

# 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
RUN ln -s $(which python3) /usr/local/bin/python || true

COPY --from=jar_builder /app/core-*.jar /
COPY scripts/ scripts/
RUN chmod -R a+x /scripts/

Expand All @@ -28,25 +41,5 @@ 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

0 comments on commit 3587a27

Please sign in to comment.