Skip to content

Commit

Permalink
init Dockerfile and compose
Browse files Browse the repository at this point in the history
  • Loading branch information
sydowma committed Oct 4, 2024
1 parent 764867b commit 057cddb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Use the official Python 3.12 image from the Docker Hub
FROM python:3.12

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file into the container
COPY . .

# Install the dependencies
RUN pip install --no-cache-dir -r requirements.txt

CMD ["python", "/app/main.py"]
13 changes: 13 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.8'

services:
app:
build:
context: .
dockerfile: Dockerfile
volumes:
- "./config.json:/app/config.json"
ports:
- "8000:8000"
environment:
- PYTHONUNBUFFERED=1
2 changes: 0 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import gitlab
import httpx
import typer
import uvicorn
from dotenv import load_dotenv
from fastapi import FastAPI
Expand Down Expand Up @@ -47,7 +46,6 @@ async def lifespan(app: FastAPI):
# 可以在这里关闭数据库连接、清理缓存等

app = FastAPI(lifespan=lifespan)
cli = typer.Typer()

# 配置文件的默认路径
DEFAULT_CONFIG_PATH = 'config.json'
Expand Down

0 comments on commit 057cddb

Please sign in to comment.