diff --git a/.dockerignore b/.dockerignore index 305b3d81b..7bfd90ff8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ .git* .idea* +installer/ \ No newline at end of file diff --git a/.github/workflows/build-and-push-python-pg.yml b/.github/workflows/build-and-push-base.yml similarity index 96% rename from .github/workflows/build-and-push-python-pg.yml rename to .github/workflows/build-and-push-base.yml index a6e356f3f..ea2356eaa 100644 --- a/.github/workflows/build-and-push-python-pg.yml +++ b/.github/workflows/build-and-push-base.yml @@ -60,4 +60,4 @@ jobs: password: ${{ secrets.GH_TOKEN }} - name: Docker Buildx (build-and-push) run: | - docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} -f installer/Dockerfile-python-pg \ No newline at end of file + docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} -f installer/Dockerfile-base \ No newline at end of file diff --git a/.github/workflows/build-and-push-vector-model.yml b/.github/workflows/build-and-push-vector-model.yml index ff667f158..5f3f0fab2 100644 --- a/.github/workflows/build-and-push-vector-model.yml +++ b/.github/workflows/build-and-push-vector-model.yml @@ -5,7 +5,7 @@ on: inputs: dockerImageTag: description: 'Docker Image Tag' - default: 'v1.0.1' + default: 'v2.0.0' required: true architecture: description: 'Architecture' @@ -19,7 +19,7 @@ on: jobs: build-and-push-vector-model-to-ghcr: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - name: Check Disk Space run: df -h @@ -55,9 +55,6 @@ jobs: ${DOCKER_IMAGE_TAGS} . - name: Set up QEMU uses: docker/setup-qemu-action@v3 - with: - # Until https://github.com/tonistiigi/binfmt/issues/215 - image: tonistiigi/binfmt:qemu-v7.0.0-28 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry diff --git a/installer/Dockerfile b/installer/Dockerfile index 789bafd50..bd6b3979d 100644 --- a/installer/Dockerfile +++ b/installer/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/1panel-dev/maxkb-vector-model:v1.0.1 AS vector-model +FROM ghcr.io/1panel-dev/maxkb-vector-model:v2.0.0 AS vector-model FROM node:18-alpine3.18 AS web-build COPY ui ui RUN cd ui && \ @@ -63,22 +63,14 @@ ENV MAXKB_VERSION="${DOCKER_IMAGE_TAG} (build at ${BUILD_AT}, commit: ${GITHUB_C WORKDIR /opt/maxkb-app COPY --from=stage-build /opt/maxkb-app /opt/maxkb-app COPY --from=stage-build /opt/py3 /opt/py3 -COPY --from=vector-model /opt/maxkb/app/model /opt/maxkb-app/model +COPY --from=vector-model /opt/maxkb-app/model /opt/maxkb-app/model -RUN chmod 755 /opt/maxkb-app/installer/*.sh && \ - cp -f /opt/maxkb-app/installer/*.sh /usr/bin/ && \ - cp -f /opt/maxkb-app/installer/init.sql /docker-entrypoint-initdb.d && \ - rm -rf /opt/maxkb-app/installer && \ - cp -r /opt/maxkb-app/model/base/hub /opt/maxkb-app/model/tokenizer && \ - curl -L --connect-timeout 120 -m 1800 https://resource.fit2cloud.com/maxkb/ffmpeg/get-ffmpeg-linux | sh && \ - mkdir -p /opt/maxkb-app/sandbox/ && \ +RUN curl -L --connect-timeout 120 -m 1800 https://resource.fit2cloud.com/maxkb/ffmpeg/get-ffmpeg-linux | sh && \ find /opt/maxkb-app -mindepth 1 -not -name 'sandbox' -exec chmod 700 {} + && \ - chmod 755 /tmp && \ useradd --no-create-home --home /opt/maxkb-app/sandbox sandbox -g root && \ chown -R sandbox:root /opt/maxkb-app/sandbox && \ chmod g-x /usr/local/bin/* /usr/bin/* /bin/* /usr/sbin/* /sbin/* /usr/lib/postgresql/17/bin/* && \ - chmod g+x /usr/local/bin/python* && \ - find /etc/ -type f ! -path '/etc/resolv.conf' ! -path '/etc/hosts' | xargs chmod g-rx + chmod g+x /usr/local/bin/python* EXPOSE 8080 VOLUME /opt/maxkb diff --git a/installer/Dockerfile-python-pg b/installer/Dockerfile-base similarity index 78% rename from installer/Dockerfile-python-pg rename to installer/Dockerfile-base index 8fc0ad22f..e2e92c268 100644 --- a/installer/Dockerfile-python-pg +++ b/installer/Dockerfile-base @@ -1,6 +1,10 @@ FROM python:3.11-slim-bullseye AS python-stage FROM postgres:17.4-bullseye +COPY --from=python-stage /usr/local /usr/local +COPY installer/*.sh /usr/bin/ +COPY installer/init.sql /docker-entrypoint-initdb.d/ + ARG DEPENDENCIES=" \ libexpat1-dev \ libffi-dev \ @@ -17,9 +21,10 @@ RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ echo "Asia/Shanghai" > /etc/timezone && \ apt-get update && apt-get install -y --no-install-recommends $DEPENDENCIES && \ apt-get clean all && \ - rm -rf /var/lib/apt/lists/* - -COPY --from=python-stage /usr/local /usr/local + rm -rf /var/lib/apt/lists/* && \ + chmod 755 /usr/bin/start-*.sh && \ + chmod 755 /tmp && \ + find /etc/ -type f ! -path '/etc/resolv.conf' ! -path '/etc/hosts' | xargs chmod g-rx ENV PGDATA=/opt/maxkb/data/postgresql/pgdata \ POSTGRES_USER=root \ diff --git a/installer/Dockerfile-vector-model b/installer/Dockerfile-vector-model new file mode 100644 index 000000000..92ef880ef --- /dev/null +++ b/installer/Dockerfile-vector-model @@ -0,0 +1,11 @@ +FROM python:3.11-slim-bookworm AS vector-model + +COPY installer/install_model.py install_model.py +RUN pip3 install --upgrade pip setuptools && \ + pip install pycrawlers && \ + pip install transformers && \ + python3 install_model.py && \ + cp -r model/base/hub model/tokenizer + +FROM scratch +COPY --from=vector-model model /opt/maxkb-app/model \ No newline at end of file