From 97d804e8016fa057fed538f28f9e76cd5287f5fe Mon Sep 17 00:00:00 2001 From: KWON Date: Mon, 30 Jun 2025 13:18:53 +0900 Subject: [PATCH] =?UTF-8?q?python-slim=20=EC=9D=84=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=ED=95=9C=20=EB=B9=8C=EB=93=9C=20=EC=B6=94=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-slim.yml | 10 ++++++++ build/Dockerfile | 10 +++++++- build/Dockerfile-slim | 54 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 build-slim.yml create mode 100644 build/Dockerfile-slim diff --git a/build-slim.yml b/build-slim.yml new file mode 100644 index 0000000..79f3018 --- /dev/null +++ b/build-slim.yml @@ -0,0 +1,10 @@ +services: + fg-auto: + build: + context: ./build + dockerfile: Dockerfile-slim + image: reg.firstgarden.co.kr/fg-auto:slim + container_name: fg-auto + volumes: + - ./data:/data + restart: unless-stopped diff --git a/build/Dockerfile b/build/Dockerfile index e8bbaed..e709ca2 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -19,7 +19,15 @@ RUN apt-get update && \ apt-get install -y ./chrome.deb && rm chrome.deb && \ apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -RUN pip3 install --no-cache-dir selenium>=4.10 pymysql ftputil pillow pyvirtualdisplay requests +# Python 패키지 설치 +RUN pip install --no-cache-dir \ + selenium>=4.10 \ + pymysql \ + ftputil \ + pillow \ + pyvirtualdisplay \ + requests + WORKDIR /data diff --git a/build/Dockerfile-slim b/build/Dockerfile-slim new file mode 100644 index 0000000..4465851 --- /dev/null +++ b/build/Dockerfile-slim @@ -0,0 +1,54 @@ +FROM python:3.10-slim + +ENV LANG=ko_KR.UTF-8 \ + LANGUAGE=ko_KR:ko \ + LC_ALL=ko_KR.UTF-8 \ + TZ=Asia/Seoul \ + DEBIAN_FRONTEND=noninteractive + +# 필수 패키지 설치 +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + locales tzdata bash cron curl unzip wget gnupg ca-certificates \ + xvfb x11-utils libglib2.0-0 libnss3 libgconf-2-4 libfontconfig1 \ + libxss1 libxshmfence1 libasound2 libxtst6 libappindicator3-1 \ + fonts-nanum libu2f-udev \ + libjpeg-dev zlib1g-dev && \ + sed -i '/ko_KR.UTF-8/s/^# //g' /etc/locale.gen && \ + locale-gen && \ + ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime && \ + ln -sf /usr/bin/python3 /usr/bin/python && \ + apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Chrome 설치 +RUN curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-linux-keyring.gpg && \ + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" \ + > /etc/apt/sources.list.d/google-chrome.list && \ + apt-get update && \ + apt-get install -y google-chrome-stable && \ + rm -rf /var/lib/apt/lists/* + +# Python 패키지 설치 +RUN pip install --no-cache-dir \ + selenium>=4.10 \ + pymysql \ + ftputil \ + pillow \ + pyvirtualdisplay \ + requests + +# 작업 디렉토리 설정 +WORKDIR /data + +# 글꼴 캐시 +RUN fc-cache -f -v + +# 실행 스크립트 복사 및 실행 권한 부여 +COPY run.sh /data/run.sh +RUN chmod +x /data/run.sh + +# crontab 직접 등록 +RUN echo "* * * * * /data/run.sh >> /proc/1/fd/1 2>&1" | crontab - + +# 크론 실행 +CMD ["bash", "-c", "cron -f"]