From 9cda382818670cfeaaf5cda17abfe9d5362320bf Mon Sep 17 00:00:00 2001 From: outlook84 <96007761+outlook84@users.noreply.github.com> Date: Wed, 4 Mar 2026 03:03:47 +0000 Subject: [PATCH] build: add alpine-based dockerfile --- Dockerfile.alpine | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Dockerfile.alpine diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 0000000000..10de51a96e --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,47 @@ +# ======== Stage 1: Builder ======== +FROM python:3.12-alpine AS builder +WORKDIR /AstrBot + +# Install build-time dependencies only +RUN apk add --no-cache \ + gcc \ + git \ + musl-dev \ + libffi-dev \ + openssl-dev \ + make + +# Install uv and generate + install Python deps +COPY . . +RUN python -m pip install --no-cache-dir uv \ + && echo "3.12" > .python-version \ + && uv lock \ + && uv export --format requirements.txt --output-file requirements.txt --frozen \ + && uv pip install -r requirements.txt --no-cache-dir --system \ + && uv pip install socksio pilk --no-cache-dir --system + +# ======== Stage 2: Runtime ======== +FROM python:3.12-alpine +WORKDIR /AstrBot + +ENV TZ=Asia/Shanghai + +# Install runtime-only dependencies +RUN apk add --no-cache \ + ca-certificates \ + bash \ + ffmpeg \ + git \ + nodejs \ + tzdata + +# Copy installed Python packages from builder +COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages +COPY --from=builder /usr/local/bin /usr/local/bin + +# Copy application source +COPY . /AstrBot/ + +EXPOSE 6185 + +CMD ["python", "main.py"] \ No newline at end of file