diff --git a/Dockerfile b/Dockerfile index 2c39a5b..10da9f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,8 +3,15 @@ FROM python:3.12-slim # Install uv. COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ + +WORKDIR /env_build + # Copy the application into the container. -COPY . /app +COPY pyproject.toml uv.lock ./ + +RUN uv sync --frozen --no-cache + +ENV PATH="/env_build/.venv/bin:$PATH" # Install the application dependencies. WORKDIR /app @@ -12,13 +19,11 @@ WORKDIR /app # 更新索引并安装替代包 RUN apt-get update && apt-get install -y vim -RUN uv sync --frozen --no-cache - +#CMD ["tail","-f","/dev/null"] # Run the application. -CMD ["tail", "-f", "/dev/null"] -#CMD ["/app/.venv/bin/gunicorn", "app.main:app", \ -# "-w", "4", \ -# "-k", "uvicorn.workers.UvicornWorker", \ -# "--bind", "0.0.0.0:80", \ -# "--access-logfile", "-", \ -# "--error-logfile", "-"] \ No newline at end of file +CMD ["gunicorn", "main:app_server", \ + "-w", "4", \ + "-k", "uvicorn.workers.UvicornWorker", \ + "--bind", "0.0.0.0:80", \ + "--access-logfile", "-", \ + "--error-logfile", "-"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e382b9c..165d41b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: dockerfile: Dockerfile working_dir: /app volumes: - - ./app:/app/app + - ./:/app - ./.env:/app/.env - /etc/localtime:/etc/localtime:ro ports: