Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-auto-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Python Packages
run: |
python -m pip install --upgrade pip
pip install google-generativeai PyGithub
pip install --no-cache-dir google-generativeai PyGithub

- name: Get Git Diff
id: git_diff
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: Build, tag, and push image to Amazon ECR
run: |
docker build -t dearbelly-cv .
docker build --no-cache -t dearbelly-cv .
docker tag dearbelly-cv:latest ${{ secrets.ECR_URI }}/dearbelly-cv
docker push ${{ secrets.ECR_URI }}/dearbelly-cv:latest

Expand Down
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ FROM nvidia/cuda:12.6.0-runtime-ubuntu24.04
WORKDIR /app

RUN apt-get update && \
apt-get install -y python3 python3-pip git && \
ln -s /usr/bin/python3 /usr/bin/python && \
pip install --upgrade pip && \
apt-get clean && rm -rf /var/lib/apt/lists/*
apt-get install -y --no-install-recommends \
python3 python3-pip python3-venv git ca-certificates && \
rm -rf /var/lib/apt/lists/*

ENV VENV_PATH=/opt/venv
RUN python3 -m venv "$VENV_PATH" && \
"$VENV_PATH/bin/python" -m pip install --upgrade pip

COPY . .
RUN "$VENV_PATH/bin/pip" install --no-cache-dir -r app/requirements.txt
Comment on lines 14 to +15

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Docker 빌드 캐시를 더 효율적으로 활용하기 위해 requirements.txt 파일만 먼저 복사하여 의존성을 설치하고, 그 다음에 나머지 애플리케이션 코드를 복사하는 것이 좋습니다.

현재 방식에서는 애플리케이션 코드의 작은 변경만 있어도 pip install 명령이 매번 다시 실행되어 빌드 시간이 길어질 수 있습니다. requirements.txt가 변경될 때만 의존성을 다시 설치하도록 하면 개발 중 빌드 속도를 크게 향상시킬 수 있습니다.

COPY app/requirements.txt app/requirements.txt
RUN "$VENV_PATH/bin/pip" install --no-cache-dir -r app/requirements.txt
COPY . .


RUN pip install --no-cache-dir -r app/requirements.txt
ENV PATH="$VENV_PATH/bin:$PATH"

EXPOSE 8000

Expand Down