-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Stage 1: Build | ||
FROM python:3.9 as build | ||
|
||
WORKDIR /app | ||
COPY ./requirements.txt /app/requirements.txt | ||
RUN pip install --no-cache-dir --user --upgrade -r /app/requirements.txt | ||
|
||
# Stage 2 : Runtime | ||
FROM python:3.9-slim as runtime | ||
|
||
WORKDIR /app | ||
|
||
# 필요한 파일들을 빌드 스테이지에서 복사 | ||
COPY --from=build /root/.local /root/.local | ||
COPY ./simple_webserver.py /app/simple_webserver.py | ||
|
||
# 환경 변수 설정 : pip install 할 때 --user로 설치하면 /root/.local에 저장됨 | ||
ENV PATH=/root/.local:$PATH | ||
|
||
# 애플리케이션 실행 | ||
CMD ["python", "simple_webserver.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Single Stage Build | ||
FROM python:3.9 | ||
|
||
WORKDIR /app | ||
COPY ./requirements.txt /app/requirements.txt | ||
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt | ||
COPY ./simple_webserver.py /app/simple_webserver.py | ||
|
||
CMD ["python", "simple_webserver.py"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fastapi==0.105.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from fastapi import FastAPI | ||
import uvicorn | ||
|
||
# FastAPI 객체 생성 | ||
app = FastAPI() | ||
|
||
|
||
# "/"로 접근하면 return을 보여줌 | ||
@app.get("/") | ||
def read_root(): | ||
return {"Hello": "World"} | ||
|
||
|
||
if __name__ == '__main__': | ||
uvicorn.run(app, host="0.0.0.0", port=8000) |