Skip to content

[RELEASE] FastAPI EC2 인스턴스에 배포#14

Merged
youyeon11 merged 1 commit intomainfrom
feat/deploy-7
Aug 28, 2025
Merged

[RELEASE] FastAPI EC2 인스턴스에 배포#14
youyeon11 merged 1 commit intomainfrom
feat/deploy-7

Conversation

@youyeon11
Copy link
Contributor

📌 작업 목적

pip 을 업그레이드 하려고하니 linux에서 차단 -> upgrade를 삭제

🗂 작업 유형

  • 버그 수정 (Bug Fix)

📎 관련 이슈


@youyeon11 youyeon11 merged commit 63df0b5 into main Aug 28, 2025
1 check failed
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @youyeon11, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 Linux 환경에서 'pip upgrade' 명령이 차단되어 발생하는 배포 문제를 해결하기 위해 'Dockerfile'을 수정합니다. 주요 변경 사항은 불필요한 'pip upgrade' 명령을 제거하고, 가상 환경 관리를 위한 'python3-venv' 패키지를 추가하여 빌드 프로세스의 안정성과 효율성을 높이는 것입니다.

Highlights

  • 배포 안정성 개선: Linux 환경에서 'pip upgrade' 명령이 차단되는 문제를 해결하기 위해 'Dockerfile'에서 해당 명령을 제거했습니다.
  • 빌드 환경 최적화: 빌드 환경의 일관성과 안정성을 위해 'Dockerfile'에 'python3-venv' 패키지 설치를 추가했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

이번 PR은 Linux 환경에서 pip 업그레이드 시 발생하는 문제를 해결하기 위해 관련 명령어를 제거하셨네요. 좋은 수정입니다.

Dockerfile을 검토하면서 한 가지 개선점을 발견했습니다. python3-venv 패키지를 추가하셨지만, 실제로는 가상 환경을 사용하고 있지 않습니다. Docker 이미지 내에서 파이썬 가상 환경을 사용하면 의존성을 격리하고 빌드 안정성을 높일 수 있습니다. 또한, Docker의 레이어 캐시를 최적화하여 빌드 속도를 향상시킬 여지도 있습니다.

관련하여 Dockerfile에 상세한 피드백과 개선 방안을 담은 코멘트를 남겼으니 확인 부탁드립니다.

Comment on lines 5 to 8
RUN apt-get update && \
apt-get install -y python3 python3-pip git && \
apt-get install -y python3 python3-venv python3-pip git && \
ln -s /usr/bin/python3 /usr/bin/python && \
pip install --upgrade pip && \
apt-get clean && rm -rf /var/lib/apt/lists/*

Choose a reason for hiding this comment

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

medium

python3-venv를 추가하신 것은 좋은 결정입니다. 하지만 현재 Dockerfile에서는 가상 환경이 사용되지 않고 있어, 패키지들이 전역으로 설치되고 있습니다. 가상 환경을 사용하면 의존성을 격리하여 더 안정적이고 예측 가능한 환경을 구축할 수 있습니다.

또한, Docker 이미지 빌드 캐시를 더 효율적으로 사용하기 위해 requirements.txt 파일을 먼저 복사하여 의존성을 설치하고, 그 다음에 나머지 소스 코드를 복사하는 것이 좋습니다. 이렇게 하면 소스 코드만 변경되었을 때 매번 의존성을 다시 설치하는 것을 피할 수 있습니다.

이 두 가지 개선 사항을 적용하여 Dockerfile을 다음과 같이 리팩토링하는 것을 제안합니다:

FROM nvidia/cuda:12.6.0-runtime-ubuntu24.04

WORKDIR /app

# 시스템 의존성 설치
RUN apt-get update && \
    apt-get install -y python3 python3-venv python3-pip git && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# 가상 환경 생성 및 PATH 설정
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# 의존성 파일만 먼저 복사하여 설치 (Docker 캐시 최적화)
COPY app/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 나머지 소스 코드 복사
COPY . .

EXPOSE 8000

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

이 리팩토링을 적용하면 ln -s /usr/bin/python3 /usr/bin/python 명령어는 더 이상 필요하지 않습니다. ENV PATH 설정을 통해 pythonpip 명령어는 자동으로 가상 환경 내의 버전을 사용하게 되기 때문입니다.

@youyeon11 youyeon11 changed the title Feat/deploy (#7) [RELEASE] FastAPI EC2 인스턴스에 배포 Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RELEASE] FastAPI EC2 인스턴스에 배포

1 participant