Update Dockerfile
Browse files- Dockerfile +5 -9
Dockerfile
CHANGED
|
@@ -6,20 +6,17 @@ RUN apt-get update && \
|
|
| 6 |
apt-get install -y --no-install-recommends git && \
|
| 7 |
rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
WORKDIR /app
|
| 11 |
ARG GITHUB_TOKEN
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
RUN git
|
| 15 |
-
git clone https://github.com/luoh-an/luoh-api.git && \
|
| 16 |
cd luoh-api && \
|
| 17 |
rm -rf .git && \
|
| 18 |
find . -type d -name "__pycache__" -exec rm -rf {} + && \
|
| 19 |
-
find . -type f -name "*.pyc" -delete
|
| 20 |
-
git config --global --unset url."https://github.com/".insteadOf
|
| 21 |
|
| 22 |
-
#
|
| 23 |
WORKDIR /app/luoh-api
|
| 24 |
|
| 25 |
# 使用非root用户
|
|
@@ -29,5 +26,4 @@ USER appuser
|
|
| 29 |
# 安装依赖
|
| 30 |
RUN pip install --user --no-cache-dir -r requirements.txt
|
| 31 |
|
| 32 |
-
EXPOSE 7860
|
| 33 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 6 |
apt-get install -y --no-install-recommends git && \
|
| 7 |
rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
+
# 必须使用构建参数传递Token
|
|
|
|
| 10 |
ARG GITHUB_TOKEN
|
| 11 |
|
| 12 |
+
# 直接使用Token克隆(需处理特殊字符)
|
| 13 |
+
RUN git clone "https://$(echo ${GITHUB_TOKEN} | sed 's/@/%40/g')@github.com/luoh-an/luoh-api.git" && \
|
|
|
|
| 14 |
cd luoh-api && \
|
| 15 |
rm -rf .git && \
|
| 16 |
find . -type d -name "__pycache__" -exec rm -rf {} + && \
|
| 17 |
+
find . -type f -name "*.pyc" -delete
|
|
|
|
| 18 |
|
| 19 |
+
# 第二阶段:应用设置
|
| 20 |
WORKDIR /app/luoh-api
|
| 21 |
|
| 22 |
# 使用非root用户
|
|
|
|
| 26 |
# 安装依赖
|
| 27 |
RUN pip install --user --no-cache-dir -r requirements.txt
|
| 28 |
|
|
|
|
| 29 |
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|