Skip to content

Commit bebebca

Browse files
Install python on java docker image instead of otherwise
python is more straightforward to install than java
1 parent e5b139a commit bebebca

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

Dockerfile

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Stage 1: Build the application
2-
FROM maven:3-eclipse-temurin-21 as builder
1+
FROM maven:3-eclipse-temurin-21 as jar_builder
32

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

14-
FROM python:3.11
13+
FROM maven:3-eclipse-temurin-21
14+
15+
# download system dependencies first to take advantage of docker caching
16+
RUN apt-get update; apt-get install -y --no-install-recommends \
17+
build-essential \
18+
default-mysql-client \
19+
default-libmysqlclient-dev \
20+
python3 \
21+
python3-setuptools \
22+
python3-dev \
23+
python3-pip \
24+
unzip \
25+
perl \
26+
&& rm -rf /var/lib/apt/lists/* \
27+
&& pip3 install wheel
1528

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

20-
# Install Perl. Some scripts are written in perl
21-
RUN apt-get update && apt-get install -y perl
33+
RUN ln -s $(which python3) /usr/local/bin/python || true
2234

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

@@ -28,25 +41,5 @@ WORKDIR /scripts/
2841

2942
ENV PORTAL_HOME=/
3043

31-
COPY --from=builder /app/core-*.jar /
32-
# Set environment variables for Java version and installation paths
33-
ENV JAVA_VERSION 21
34-
ENV JAVA_HOME /usr/java/openjre-$JAVA_VERSION
35-
36-
# Install necessary packages for adding repositories over HTTPS
37-
RUN apt-get update && \
38-
apt-get install -y --no-install-recommends apt-transport-https ca-certificates wget dirmngr gnupg software-properties-common && \
39-
rm -rf /var/lib/apt/lists/*
40-
41-
# Download and install OpenJRE 21
42-
# Note: The exact URL might change based on the latest available version, so replace it with the correct URL for JRE 21
43-
RUN mkdir -p "$JAVA_HOME" && \
44-
wget -O jdk21.tar.gz "https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz" && \
45-
tar xvf jdk21.tar.gz --strip-components=1 -C "$JAVA_HOME" && \
46-
rm jdk21.tar.gz
47-
48-
# Add java to PATH
49-
ENV PATH $JAVA_HOME/bin:$PATH
50-
5144
# This file is empty. It has to be overriden by bind mounting the actual application.properties
5245
RUN touch /application.properties

0 commit comments

Comments
 (0)