Chore: Dockerfile (#3266)

* fix: Dockerfile

python main.py 改为uv run main.py

* fix(dockerfile): 减少重复安装

* fix: 修复一些细节问题

* fix(.dockerignore): 需要git文件夹以获取astrbot版本(带git commit hash后缀)

* fix(.dockerignore): uv run之前会uv sync
This commit is contained in:
LIghtJUNction
2025-11-03 02:41:40 +08:00
committed by GitHub
parent 50144ddcae
commit 74f845b06d
3 changed files with 28 additions and 22 deletions
+1 -3
View File
@@ -1,9 +1,8 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# github acions
# github actions
.github/
.*ignore
.git/
# User-specific stuff
.idea/
# Byte-compiled / optimized / DLL files
@@ -15,7 +14,6 @@ env/
venv*/
ENV/
.conda/
README*.md
dashboard/
data/
changelogs/
+11 -8
View File
@@ -12,19 +12,22 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
bash \
ffmpeg \
nodejs \
curl \
gnupg \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get update && apt-get install -y curl gnupg && \
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs && \
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y --no-install-recommends nodejs && \
echo "3.11" > .python-version && \
rm -rf /var/lib/apt/lists/*
RUN python -m pip install uv
RUN uv pip install -r requirements.txt --no-cache-dir --system
RUN uv pip install socksio uv pilk --no-cache-dir --system
RUN python -m pip install --no-cache-dir uv && \
uv pip install socksio pilk --no-cache-dir --system
EXPOSE 6185
EXPOSE 6186
CMD [ "python", "main.py" ]
CMD ["uv", "run", "main.py"]
+16 -11
View File
@@ -1,4 +1,4 @@
FROM python:3.10-slim
FROM python:3.11-slim
WORKDIR /AstrBot
@@ -14,22 +14,27 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
unzip \
ca-certificates \
bash \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Installation of Node.js
ENV NVM_DIR="/root/.nvm"
ENV NVM_DIR="/root/.nvm" \
NODE_VERSION=22
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash && \
. "$NVM_DIR/nvm.sh" && \
nvm install 22 && \
nvm use 22
RUN /bin/bash -c ". \"$NVM_DIR/nvm.sh\" && node -v && npm -v"
nvm install $NODE_VERSION && \
nvm use $NODE_VERSION && \
nvm alias default $NODE_VERSION && \
node -v && npm -v && \
echo "3.11" > .python-version
ENV PATH="$NVM_DIR/versions/node/v$(node -v | cut -d 'v' -f 2)/bin:$PATH"
RUN python -m pip install uv
RUN uv pip install -r requirements.txt --no-cache-dir --system
RUN uv pip install socksio uv pyffmpeg --no-cache-dir --system
RUN python -m pip install --no-cache-dir uv
# 安装项目依赖(根据指南,使用 uv sync)
RUN uv sync --no-cache
EXPOSE 6185
EXPOSE 6186
CMD ["python", "main.py"]
CMD ["uv", "run", "main.py"]