I am working on a Java 17 and Maven 3.9.6-based robotic automation application that automates Chrome through Selenium. to perform report download tasks. This operation works fine when performed in a local development environment and as an executable jar, file.
But when I am attempting to dockerize this application I am facing issues related to selenium and browser dependencies when building and attempting to run the docker image.
Use the official OpenJDK 17 image as a base image
FROM maven:3.9.6-eclipse-temurin-17-alpine AS builder
Set the working directory inside the container
WORKDIR /app
RUN chmod -R 777 /app
Install tools.
RUN apt update -y & apt install -y wget unzip
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y tzdata
Install Chrome.
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get update
RUN apt-get install -y google-chrome-stable
Install ChromeDriver.
RUN wget -N https://chromedriver.storage.googleapis.com/105.0.5195.19/chromedriver_linux64.zip -P ~/
RUN unzip ~/chromedriver_linux64.zip -d ~/
RUN rm ~/chromedriver_linux64.zip
RUN mv -f ~/chromedriver /usr/local/bin/chromedriver
RUN chmod +x /usr/local/bin/chromedriver
Copy the entire project (assuming Dockerfile is in the project root)
COPY . .
Build the application using Maven
RUN mvn package -DskipTests
Use the official OpenJDK 17 image as the final image
FROM eclipse-temurin:17.0.6_10-jdk@sha256:13817c2faa739c0351f97efabed0582a26e9e6745a6fb9c47d17f4365e56327d
Set the working directory inside the container
WORKDIR /app
Copy the JAR file and other necessary files to the container
COPY report-automation.jar /app/report-automation.jar
COPY src/main/resources/META-INF/MANIFEST.MF /app/META-INF/MANIFEST.MF
COPY src /app/src
COPY src/main/resources/META-INF/MANIFEST.MF /app/META-INF/MANIFEST.MF
COPY src/main/resources/config.properties /app/config.properties
COPY pom.xml /app/pom.xml
COPY testng.xml /app/testng.xml
COPY application.properties /app/application.properties
COPY Configuration.xlsm /app/Configuration.xlsm
COPY apache-maven-3.9.6/ /app/apache-maven-3.9.6/
COPY Downloads /app/Downloads
COPY Logs /app/Logs
COPY report /app/report
COPY Reports /app/Reports
Expose the port (if your application listens on a specific port)
EXPOSE 8080
Set the entry point for the container (replace with your main class)
ENTRYPOINT ["java", "-jar", "report-automation.jar"]
These are the more useful references I came across. But I still seem to be missing something and facing issues.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/007f8ea9-15d7-4afa-928d-09d42ccb8238n%40googlegroups.com.