Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
9git9git
fastapi_deploy_tutorial
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
fastapi_deploy_tutorial
/
Dockerfile
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
47 lines (37 loc) · 1.99 KB
main
Breadcrumbs
fastapi_deploy_tutorial
/
Dockerfile
Copy path
Top
File metadata and controls
Code
Blame
47 lines (37 loc) · 1.99 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
FROM python:3.9-slim
# 시스템 패키지 업데이트 및 필요한 의존성 설치
# - apt-get update: Ubuntu/Debian 패키지 목록 최신화
# - build-essential: C/C++ 컴파일러 등 기본 빌드 도구 설치
# (일부 Python 패키지는 설치 시 C/C++ 코드 컴파일이 필요하며, 이를 위한 도구)
# - curl: URL을 통해 데이터를 전송하는 도구 설치
# - rm -rf: 패키지 캐시를 삭제하여 이미지 크기 최적화
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Poetry 설치 시 네트워크 타임아웃 설정
ENV POETRY_HTTP_TIMEOUT=120
# Poetry 설치 및 PATH 설정
# - curl로 Poetry 설치 스크립트 다운로드 및 실행
# - ln -s: Poetry 실행 파일의 심볼릭 링크를 생성하여 전역 접근 가능하게 함
# (심볼릭 링크는 원본 파일을 가리키는 바로가기와 같은 것으로,
# /root/.local/bin/poetry를 /usr/local/bin/poetry에서도 접근 가능하게 함)
RUN curl -sSL https://install.python-poetry.org | python3 - && \
ln -s /root/.local/bin/poetry /usr/local/bin/poetry
# Poetry 가상환경 생성 비활성화 (Docker 컨테이너 내부에서는 불필요)
RUN poetry config virtualenvs.create false
# 의존성 파일만 먼저 복사 및 설치 (레이어 캐싱 최적화)
# --only main: 개발 의존성 제외하고 주요 의존성만 설치
# --no-root: 현재 프로젝트를 설치하지 않고 의존성만 설치 (캐싱 최적화)
# --no-interaction: 사용자 입력 없이 자동 설치
COPY pyproject.toml poetry.lock* ./
RUN poetry install --only main --no-root --no-interaction
# 모든 애플리케이션 코드를 컨테이너로 복사
COPY . .
EXPOSE 8000
# Python 경로에 현재 디렉토리 추가
ENV PYTHONPATH=/app
# FastAPI 애플리케이션 실행
# app.main:app은 app 패키지의 main 모듈에서 app 인스턴스를 찾아 실행
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
You can’t perform that action at this time.