How to create docker image combining Spring boot app and python3 with libraries?

  docker, numpy, opencv, python-3.x, spring-boot

all! I’m new to docker and I faced with problem how to combine Spring boot application with python 3 and it’s libraries like opencv and numpy. I need it because my server uses python scripts to processing images.

I tried a lot of methods which I read here (in StackOverflow): I tried alpine and ubuntu as base images, I tried make a multistage build… Here’s one of my attempts with ubuntu:

FROM ubuntu:20.04
RUN apt install openjdk-14-jre-headless
RUN apt install -y python3-pip
RUN apt install build-essential libssl-dev libffi-dev python3-dev
RUN pip3 install numpy && pip3 intall opencv-python

EXPOSE 8080
COPY ./scripts ./scripts
ARG JAR_FILE=target/*.jar
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

And with another base image which consists of proper libraries:

FROM patavee/scipy-matplotlib-opencv-py3

FROM openjdk:14
EXPOSE 8080
COPY ./scripts ./scripts
ARG JAR_FILE=target/*.jar
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

What should I try next to success?

Source: Docker Questions

LEAVE A COMMENT