启动脚本

This commit is contained in:
zjw
2026-04-16 09:50:13 +08:00
parent 7adc88bab7
commit e753609249
4 changed files with 42 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
FROM python:3.12-slim FROM registry.bjzgzp.com:4433/library/python3.12:base
WORKDIR /app WORKDIR /app
@@ -15,4 +15,4 @@ COPY . .
EXPOSE 8000 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"]

View File

@@ -1,5 +1,5 @@
server: server:
port: 8000 port: 18000
log_level: INFO log_level: INFO
storage: storage:

12
docker-compose.python.yml Normal file
View File

@@ -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

27
start.sh Normal file
View File

@@ -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"