유명현

Add Dockerfile, docker-compose.yml, etc.

1 +FROM python:3
2 +
3 +WORKDIR /usr/src/app
4 +
5 +EXPOSE 8080
6 +
7 +COPY . .
8 +RUN pip install --no-cache-dir -r requirements.txt
9 +
10 +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]
...\ No newline at end of file ...\ No newline at end of file
1 +docker build . -t daangn
2 +docker-compose up -d
...\ No newline at end of file ...\ No newline at end of file
1 +version: "3"
2 +
3 +services:
4 + api:
5 + build:
6 + context: .
7 + dockerfile: ./Dockerfile
8 + ports:
9 + - 18080:8080
...@@ -5,7 +5,7 @@ import daangn_crawl ...@@ -5,7 +5,7 @@ import daangn_crawl
5 # uvicorn main:app --reload 5 # uvicorn main:app --reload
6 app = FastAPI() 6 app = FastAPI()
7 7
8 -@app.get("/daangn/{item}") 8 +@app.get("/api/v2/daangn/{item}")
9 def read_item(item: str, q: Optional[str] = None): 9 def read_item(item: str, q: Optional[str] = None):
10 crawl_json = daangn_crawl.crawl(item) 10 crawl_json = daangn_crawl.crawl(item)
11 return crawl_json 11 return crawl_json
...\ No newline at end of file ...\ No newline at end of file
......
1 +beautifulsoup4==4.10.0
2 +fastapi==0.77.1
3 +requests==2.27.1
4 +uvicorn==0.17.6
1 +docker-compose down
2 +docker image rm daangn
...\ No newline at end of file ...\ No newline at end of file