mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 18:01:42 +00:00
docker build-server step can fail with errors below, requiring setuptools module installed: 35 120.7 npm error code 1 35 120.7 npm error path /server/node_modules/sqlite3 35 120.7 npm error command failed 35 120.7 npm error command sh -c prebuild-install -r napi || node-gyp rebuild 35 120.7 npm error prebuild-install warn install No prebuilt binaries found (target=6 runtime=napi arch=arm libc=musl platform=linux) 35 120.7 npm error gyp info it worked if it ends with ok 35 120.7 npm error gyp info using node-gyp@8.4.1 35 120.7 npm error gyp info using node@20.19.4 | linux | arm 35 120.7 npm error gyp info find Python using Python version 3.12.11 found at "/usr/bin/python3" 35 120.7 npm error gyp http GET https://nodejs.org/download/release/v20.19.4/node-v20.19.4-headers.tar.gz 35 120.7 npm error gyp http 200 https://nodejs.org/download/release/v20.19.4/node-v20.19.4-headers.tar.gz 35 120.7 npm error gyp http GET https://nodejs.org/download/release/v20.19.4/SHASUMS256.txt 35 120.7 npm error gyp http 200 https://nodejs.org/download/release/v20.19.4/SHASUMS256.txt 35 120.7 npm error gyp info spawn /usr/bin/python3 35 120.7 npm error gyp info spawn args [ 35 120.7 npm error gyp info spawn args '/server/node_modules/node-gyp/gyp/gyp_main.py', 35 120.7 npm error gyp info spawn args 'binding.gyp', 35 120.7 npm error gyp info spawn args '-f', 35 120.7 npm error gyp info spawn args 'make', 35 120.7 npm error gyp info spawn args '-I', 35 120.7 npm error gyp info spawn args '/server/node_modules/sqlite3/build/config.gypi', 35 120.7 npm error gyp info spawn args '-I', 35 120.7 npm error gyp info spawn args '/server/node_modules/node-gyp/addon.gypi', 35 120.7 npm error gyp info spawn args '-I', 35 120.7 npm error gyp info spawn args '/root/.cache/node-gyp/20.19.4/include/node/common.gypi', 35 120.7 npm error gyp info spawn args '-Dlibrary=shared_library', 35 120.7 npm error gyp info spawn args '-Dvisibility=default', 35 120.7 npm error gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/20.19.4', 35 120.7 npm error gyp info spawn args '-Dnode_gyp_dir=/server/node_modules/node-gyp', 35 120.7 npm error gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/20.19.4/<(target_arch)/node.lib', 35 120.7 npm error gyp info spawn args '-Dmodule_root_dir=/server/node_modules/sqlite3', 35 120.7 npm error gyp info spawn args '-Dnode_engine=v8', 35 120.7 npm error gyp info spawn args '--depth=.', 35 120.7 npm error gyp info spawn args '--no-parallel', 35 120.7 npm error gyp info spawn args '--generator-output', 35 120.7 npm error gyp info spawn args 'build', 35 120.7 npm error gyp info spawn args '-Goutput_dir=.' 35 120.7 npm error gyp info spawn args ] 35 120.7 npm error Traceback (most recent call last): 35 120.7 npm error File "/server/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module> 35 120.7 npm error import gyp # noqa: E402 35 120.7 npm error ^^^^^^^^^^ 35 120.7 npm error File "/server/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 9, in <module> 35 120.7 npm error import gyp.input 35 120.7 npm error File "/server/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in <module> 35 120.7 npm error from distutils.version import StrictVersion 35 120.7 npm error ModuleNotFoundError: No module named 'distutils'
76 lines
1.9 KiB
Docker
76 lines
1.9 KiB
Docker
ARG NUSQLITE3_DIR="/usr/local/lib/nusqlite3"
|
|
ARG NUSQLITE3_PATH="${NUSQLITE3_DIR}/libnusqlite3.so"
|
|
|
|
### STAGE 0: Build client ###
|
|
FROM --platform=$BUILDPLATFORM node:20-alpine AS build-client
|
|
|
|
WORKDIR /client
|
|
COPY /client /client
|
|
RUN npm ci && npm cache clean --force
|
|
RUN npm run generate
|
|
|
|
### STAGE 1: Build server ###
|
|
FROM node:20-alpine AS build-server
|
|
|
|
ARG NUSQLITE3_DIR
|
|
ARG TARGETPLATFORM
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
RUN apk add --no-cache --update \
|
|
curl \
|
|
make \
|
|
python3 \
|
|
py3-setuptools \
|
|
g++ \
|
|
unzip
|
|
|
|
WORKDIR /server
|
|
COPY index.js package* /server
|
|
COPY /server /server/server
|
|
|
|
RUN case "$TARGETPLATFORM" in \
|
|
"linux/amd64") \
|
|
curl -L -o /tmp/library.zip "https://github.com/mikiher/nunicode-sqlite/releases/download/v1.2/libnusqlite3-linux-musl-x64.zip" ;; \
|
|
"linux/arm64") \
|
|
curl -L -o /tmp/library.zip "https://github.com/mikiher/nunicode-sqlite/releases/download/v1.2/libnusqlite3-linux-musl-arm64.zip" ;; \
|
|
"linux/arm/v7") \
|
|
curl -L -o /tmp/library.zip "https://github.com/mikiher/nunicode-sqlite/releases/download/v1.2/libnusqlite3-linux-musl-armv7l.zip" ;; \
|
|
*) echo "Unsupported platform: $TARGETPLATFORM" && exit 1 ;; \
|
|
esac && \
|
|
unzip /tmp/library.zip -d $NUSQLITE3_DIR && \
|
|
rm /tmp/library.zip
|
|
|
|
RUN npm ci --only=production
|
|
|
|
### STAGE 2: Create minimal runtime image ###
|
|
FROM node:20-alpine
|
|
|
|
ARG NUSQLITE3_DIR
|
|
ARG NUSQLITE3_PATH
|
|
|
|
# Install only runtime dependencies
|
|
RUN apk add --no-cache --update \
|
|
tzdata \
|
|
ffmpeg \
|
|
tini
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy compiled frontend and server from build stages
|
|
COPY --from=build-client /client/dist /app/client/dist
|
|
COPY --from=build-server /server /app
|
|
COPY --from=build-server ${NUSQLITE3_PATH} ${NUSQLITE3_PATH}
|
|
|
|
EXPOSE 80
|
|
|
|
ENV PORT=80
|
|
ENV NODE_ENV=production
|
|
ENV CONFIG_PATH="/config"
|
|
ENV METADATA_PATH="/metadata"
|
|
ENV SOURCE="docker"
|
|
ENV NUSQLITE3_DIR=${NUSQLITE3_DIR}
|
|
ENV NUSQLITE3_PATH=${NUSQLITE3_PATH}
|
|
|
|
ENTRYPOINT ["tini", "--"]
|
|
CMD ["node", "index.js"]
|