Dockerfile
# docker build --platform linux/amd64 -t ai-vanna:latest .
FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Change the working directory to the `app` directory
WORKDIR /app
# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --locked --no-install-project
# Copy the project into the image
ADD . /app
EXPOSE 6060
# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked
ENTRYPOINT ["sh", "-c", "uv run train.py && uv run server.py"]
docker-compose.yml
version: '3'
services:
ai-vanna:
image: ai-vanna:latest
ports:
- "6060:6060"
volumes:
- ./data:/app/data
- ./train_data:/app/train_data
- ./config.py:/app/config.py
restart: always
脚本
# 生成镜像
docker build --platform linux/amd64 -t ai-vanna:latest .
# 导出镜像
docker save -o .tar ai-vanna:latest
# 加载镜像
docker load -i .tar
#重命名镜像
docker tag nginx:1.23 my_nginx:1.23
#打开镜像运行环境
docker exec -it 6408cc170462 /bin/bash