Infra

Docker 배포한 Spring Boot 프로젝트 Selenium 사용하기

joaa 2023. 11. 22. 21:21

구글 크롬 업데이트 막기

 echo "google-chrome-stable hold" | sudo dpkg --set-selections 

 

 

 

 

크롬, 크롬드라이버 설치

https://synuns.tistory.com/13

 

[AWS] ec2(ubuntu)에서 selenium 사용하기

aws 환경에서 selenium을 사용해야하는 경우에는 크롬드라이버 관련 설치로 환경설정이 필요하다. 최근에 환경 설정을 하게 되어서 관련 자료들을 정리한다. Ubuntu 업데이트 및 필수 패키지 설치 //

synuns.tistory.com

 

 

 

 

최신 크롬 버전에 맞는 크롬드라이버 설치

https://velog.io/@syiee/Chrome-Web-Driver-%EC%B5%9C%EC%8B%A0-%EB%B2%84%EC%A0%84-%EC%84%A4%EC%B9%98-%EB%B0%A9%EB%B2%95-119

 

Chrome Web Driver 최신 버전 설치 방법 119.**

최근 Selenium 을 사용해 웹 크롤링을 하는데 이때 크롬 웹드라이버가 필요했다. 그런데 크롬을 실행할 때마다 자동으로 버전이 업데이트 되면서 새로운 드라이버 버전으로 맞추어 주어야 했다.우

velog.io

https://github.com/GoogleChromeLabs/chrome-for-testing/blob/main/data/latest-versions-per-milestone-with-downloads.json

 

 

 

 

 

난 spring boot jar 파일을 도커 컨테이너에서 실행시키니까 ubuntu에 설치하는건 의미가 없음. 

Dockerfile에 chrome과 chromedriver 설치 명령을 해야함. 

도커 컨테이너에 크롬, 크롬드라이버를 설치하는건데

크롬은 매번 최신 버전을 다운받는데

크롬드라이버는 119버전을 다운받도록 해놓아서 나중에 크롬 업데이트가 되면 문제가 생길 것 같음. 

대략 4주에 한 번 업데이트한다는 것 같음. 

FROM openjdk:11
WORKDIR /usr/src
RUN apt-get -y update
RUN apt install wget
RUN apt install unzip
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt -y install ./google-chrome-stable_current_amd64.deb
RUN wget -O /tmp/chromedriver.zip https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/119.0.6045.105/linux64/chromedriver-linux64.zip
RUN unzip /tmp/chromedriver.zip -d /usr/src
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} ./app.jar
ENTRYPOINT ["java","-jar","./app.jar"]

 

 

 

container log 조회

docker logs {container id}