Spaces:
Runtime error
Runtime error
| # Basic mirror image | |
| FROM alpine:edge as base | |
| # Maintenanceer information | |
| LABEL maintainer "a76yyyy <q981331502@163.com>" | |
| LABEL org.opencontainers.image.source=https://github.com/qiandao-today/ddddocr-docker | |
| # Envirenment for onnxruntime | |
| ENV ONNXRUNTIME_TAG=v1.13.1 | |
| # Replace the alpine image source & Install packages | |
| RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \ | |
| echo 'http://mirrors.ustc.edu.cn/alpine/v3.16/main' >> /etc/apk/repositories && \ | |
| echo 'http://mirrors.ustc.edu.cn/alpine/v3.16/community' >> /etc/apk/repositories && \ | |
| apk update && \ | |
| apk add --update --no-cache bash git tzdata nano openssh-client ca-certificates file python3 py3-pip py3-setuptools py3-wheel && \ | |
| # ln -s /usr/bin/python3 /usr/bin/python && \ | |
| [[ $(getconf LONG_BIT) = "32" ]] && \ | |
| { bashtmp='' && cxxtmp=''; } || { \ | |
| [[ -z $(file /bin/busybox | grep -i "arm") ]] && \ | |
| { bashtmp='/onnxruntime/build.sh' && cxxtmp=''; } || \ | |
| { bashtmp='setarch arm64 /onnxruntime/build.sh' && cxxtmp='-Wno-psabi'; }; } && \ | |
| echo $bashtmp && echo $cxxtmp && {\ | |
| [[ -n "$bashtmp" ]] && { \ | |
| apk add --update --no-cache py3-numpy-dev py3-opencv py3-pillow && {\ | |
| apk add --update --no-cache --virtual .build_deps cmake make perl autoconf g++=11.2.1_git20220219-r2 libexecinfo-dev=1.1-r1 automake linux-headers libtool util-linux openblas-dev python3-dev protobuf-dev date-dev gtest-dev eigen-dev py3-pybind11-dev flatbuffers-dev=2.0.0-r1 patch boost-dev nlohmann-json || \ | |
| apk add --update --no-cache --virtual .build_deps cmake make perl autoconf g++=11.2.1_git20220219-r2 libexecinfo-dev=1.1-r1 automake linux-headers libtool util-linux openblas-dev python3-dev protobuf-dev date-dev gtest-dev eigen-dev py3-pybind11-dev patch boost-dev nlohmann-json ;} && \ | |
| git clone --depth 1 --branch $ONNXRUNTIME_TAG https://github.com/Microsoft/onnxruntime && \ | |
| cd /onnxruntime && \ | |
| git submodule update --init --recursive && \ | |
| cd .. && \ | |
| $bashtmp --config MinSizeRel \ | |
| --parallel \ | |
| --build_wheel \ | |
| --enable_pybind \ | |
| --cmake_extra_defines \ | |
| CMAKE_CXX_FLAGS="-Wno-deprecated-copy -Wno-unused-variable -Wno-unused-parameter $cxxtmp"\ | |
| onnxruntime_BUILD_UNIT_TESTS=OFF \ | |
| onnxruntime_BUILD_SHARED_LIB=OFF \ | |
| onnxruntime_USE_PREINSTALLED_EIGEN=ON \ | |
| onnxruntime_PREFER_SYSTEM_LIB=ON \ | |
| eigen_SOURCE_PATH=/usr/include/eigen3 \ | |
| --skip_tests && \ | |
| apk add --update --no-cache libprotobuf-lite && \ | |
| pip install --no-cache-dir /onnxruntime/build/Linux/MinSizeRel/dist/onnxruntime*.whl && \ | |
| ln -s $(python -c 'import warnings;warnings.filterwarnings("ignore");\ | |
| from distutils.sysconfig import get_python_lib;pr(get_python_lib())')/onnxruntime/capi/libonnxruntime_providers_shared.so /usr/lib && \ | |
| cd / && rm -rf /onnxruntime && \ | |
| apk del .build_deps ;} || { \ | |
| apk add --update --no-cache libprotobuf-lite && \ | |
| echo "Onnxruntime Builder does not currently support building i386 and arm32 wheels";} ;} && \ | |
| rm -rf /var/cache/apk/* && \ | |
| rm -rf /usr/share/man/* | |
| # Install dependencies only when needed | |
| FROM base AS deps | |
| # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | |
| RUN apk add --no-cache libc6-compat | |
| WORKDIR /app | |
| # Install dependencies based on the preferred package manager | |
| COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | |
| RUN \ | |
| if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | |
| elif [ -f package-lock.json ]; then npm ci; \ | |
| elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i --frozen-lockfile; \ | |
| else echo "Lockfile not found." && exit 1; \ | |
| fi | |
| # Uncomment the following lines if you want to use a secret at buildtime, | |
| # for example to access your private npm packages | |
| # RUN --mount=type=secret,id=HF_EXAMPLE_SECRET,mode=0444,required=true \ | |
| # $(cat /run/secrets/HF_EXAMPLE_SECRET) | |
| # Rebuild the source code only when needed | |
| FROM base AS builder | |
| WORKDIR /app | |
| COPY --from=deps /app/node_modules ./node_modules | |
| COPY . . | |
| # Next.js collects completely anonymous telemetry data about general usage. | |
| # Learn more here: https://nextjs.org/telemetry | |
| # Uncomment the following line in case you want to disable telemetry during the build. | |
| # ENV NEXT_TELEMETRY_DISABLED 1 | |
| # RUN yarn build | |
| # If you use yarn, comment out this line and use the line above | |
| RUN npm run build | |
| # Production image, copy all the files and run next | |
| FROM base AS runner | |
| WORKDIR /app | |
| ENV NODE_ENV production | |
| # Uncomment the following line in case you want to disable telemetry during runtime. | |
| # ENV NEXT_TELEMETRY_DISABLED 1 | |
| RUN addgroup --system --gid 1001 nodejs | |
| RUN adduser --system --uid 1001 nextjs | |
| COPY --from=builder /app/public ./public | |
| # Automatically leverage output traces to reduce image size | |
| # https://nextjs.org/docs/advanced-features/output-file-tracing | |
| COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | |
| COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | |
| USER nextjs | |
| EXPOSE 3000 | |
| ENV PORT 3000 | |
| CMD ["node", "server.js"] |