From e7536092498f8d2ef57b4f10bee6de90980e392d Mon Sep 17 00:00:00 2001 From: zjw <2956131242@qq.com> Date: Thu, 16 Apr 2026 09:50:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E5=8A=A8=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++-- config.yaml | 2 +- docker-compose.python.yml | 12 ++++++++++++ start.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 docker-compose.python.yml create mode 100644 start.sh diff --git a/Dockerfile b/Dockerfile index c6fdd28..47f61e2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-slim +FROM registry.bjzgzp.com:4433/library/python3.12:base WORKDIR /app @@ -15,4 +15,4 @@ COPY . . EXPOSE 8000 -CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] +CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "18000"] diff --git a/config.yaml b/config.yaml index 2e68628..925435a 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,5 @@ server: - port: 8000 + port: 18000 log_level: INFO storage: diff --git a/docker-compose.python.yml b/docker-compose.python.yml new file mode 100644 index 0000000..d852fb6 --- /dev/null +++ b/docker-compose.python.yml @@ -0,0 +1,12 @@ +version: "3.9" + +services: + python-service: + image: label-ai-service:latest + build: + context: . + dockerfile: Dockerfile + container_name: label-ai-service + ports: + - "18000:18000" + restart: unless-stopped diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..93204af --- /dev/null +++ b/start.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$SCRIPT_DIR" + +COMPOSE_CMD="docker compose" +if ! docker compose version >/dev/null 2>&1; then + if command -v docker-compose >/dev/null 2>&1; then + COMPOSE_CMD="docker-compose" + else + echo "Error: docker compose and docker-compose are both unavailable." >&2 + exit 1 + fi +fi + +echo "==> Pulling latest code..." +git pull + +echo "==> Building image..." +docker build -t label-ai-service:latest -f Dockerfile . + +echo "==> Starting service..." +$COMPOSE_CMD -f docker-compose.python.yml up -d + +echo "==> Service started. Check logs with:" +echo " $COMPOSE_CMD -f docker-compose.python.yml logs -f python-service"