FROM ubuntu:22.04

# 관련 패키지 설치
RUN apt-get update && apt-get install -y mecab libmecab-dev mecab-ipadic-utf8 vim gcc g++ python3.10 python3-pip locales

RUN localedef -f UTF-8 -i ko_KR ko_KR.UTF-8
ENV LC_ALL ko_KR.UTF-8
ENV PYTHONIOENCODING=utf-8

# jdk 설치
RUN apt-get install -y openjdk-8-jdk

# eunjeon 패키지 따로 설치
RUN pip install eunjeon

# jdk 설정
RUN echo "export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64" >> /etc/profile && \
    echo "export CLASSPATH=.:$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/lib/jsp-api.jar:$CATALINA_HOME/lib/servlet-api.jar" >> /etc/profile && \
    echo "export LANG=ko_KR.UTF-8" >> /etc/profile

WORKDIR /fastapi_new
# 이미지 내부에 필요한 파일을 복사
COPY ./fastapi_new .

RUN apt-get update && \
    apt-get install -y \
    wget \
    curl \
    gnupg \
    jq \
    unzip \
    libu2f-udev \
    libappindicator3-1 \
    libasound2 \
    libatk-bridge2.0-0 \
    libatk1.0-0 \
    libcups2 \
    libdbus-1-3 \
    libgtk-3-0 \
    libnspr4 \
    libnss3 \
    libx11-xcb1 \
    libxcomposite1 \
    libxcursor1 \
    libxdamage1 \
    libxfixes3 \
    libxi6 \
    libxrandr2 \
    libxss1 \
    libxtst6 \
    xdg-utils \
    fonts-liberation \
    libgbm1 \
    libvulkan1 \
    && apt-get clean

# 크롬 자동 설치
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list
RUN apt-get update && apt-get install -y google-chrome-stable

# 크롬 실행 확인
RUN google-chrome --version

RUN mkdir -p /dev/shm && chmod 1777 /dev/shm

RUN pip install --no-cache-dir -r requirements.txt

#CMD
CMD ["python3","main.py"]

