Skip to content

Commit e8cbea4

Browse files
build: optimize Dockerfile.
1 parent 16718dc commit e8cbea4

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

installer/Dockerfile

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,22 @@ RUN cd ui && ls -la && if [ -d "dist" ]; then exit 0; fi && \
66
NODE_OPTIONS="--max-old-space-size=4096" npx concurrently "npm run build" "npm run build-chat" && \
77
find . -maxdepth 1 ! -name '.' ! -name 'dist' ! -name 'public' -exec rm -rf {} +
88

9-
FROM ghcr.io/1panel-dev/maxkb-base:python3.11-pg17.6 AS stage-build
10-
11-
RUN apt-get update && \
12-
apt-get install -y --no-install-recommends python3-pip && \
13-
apt-get clean all && \
14-
rm -rf /var/lib/apt/lists/*
15-
9+
FROM ghcr.io/1panel-dev/maxkb-base:python3.11-pg17.6 AS deps-install
1610
COPY --chmod=700 . /opt/maxkb-app
11+
WORKDIR /opt/maxkb-app
12+
RUN pip install uv --break-system-packages && \
13+
python -m uv pip install -r pyproject.toml && \
14+
python -m uv pip install --target=/opt/maxkb-app/sandbox/python-packages requests pymysql psycopg2-binary
1715

16+
FROM ghcr.io/1panel-dev/maxkb-base:python3.11-pg17.6 AS apps-build
17+
COPY --chmod=700 . /opt/maxkb-app
1818
WORKDIR /opt/maxkb-app
1919
RUN rm -rf /opt/maxkb-app/ui && \
20-
pip install uv --break-system-packages && \
21-
python -m uv pip install -r pyproject.toml && \
2220
find /opt/maxkb-app -depth \( -name ".git*" -o -name ".docker*" -o -name ".idea*" -o -name ".editorconfig*" -o -name ".prettierrc*" -o -name "README.md" -o -name "poetry.lock" -o -name "pyproject.toml" \) -exec rm -rf {} + && \
23-
export MAXKB_CONFIG_TYPE=ENV && python3 /opt/maxkb-app/apps/manage.py compilemessages && \
24-
export PIP_TARGET=/opt/maxkb-app/sandbox/python-packages && \
25-
python -m uv pip install --target=$PIP_TARGET requests pymysql psycopg2-binary && \
21+
python3 /opt/maxkb-app/apps/manage.py compilemessages && \
2622
rm -rf /opt/maxkb-app/installer
2723
COPY --from=web-build --chmod=700 ui /opt/maxkb-app/ui
24+
COPY --from=deps-install /opt/maxkb-app/sandbox/python-packages /opt/maxkb-app/sandbox/python-packages
2825

2926
FROM ghcr.io/1panel-dev/maxkb-base:python3.11-pg17.6
3027
ARG DOCKER_IMAGE_TAG=dev \
@@ -49,10 +46,9 @@ ENV MAXKB_VERSION="${DOCKER_IMAGE_TAG} (build at ${BUILD_AT}, commit: ${GITHUB_C
4946
MAXKB_LOCAL_MODEL_PROTOCOL=http \
5047
PIP_TARGET=/opt/maxkb/python-packages
5148

52-
5349
WORKDIR /opt/maxkb-app
54-
COPY --from=stage-build /opt/maxkb-app /opt/maxkb-app
55-
COPY --from=stage-build /opt/py3 /opt/py3
50+
COPY --from=apps-build /opt/maxkb-app /opt/maxkb-app
51+
COPY --from=deps-install /opt/py3/lib/python3.11/site-packages /opt/py3/lib/python3.11/site-packages
5652

5753
RUN chmod 755 /tmp
5854

0 commit comments

Comments
 (0)