|
| 1 | +FROM node:22-bookworm-slim AS builder |
| 2 | + |
| 3 | +WORKDIR /cube |
| 4 | + |
| 5 | +# Copy only the custom package.json |
| 6 | +COPY custom-package.json package.json |
| 7 | + |
| 8 | +RUN yarn policies set-version v1.22.22 |
| 9 | +RUN yarn config set network-timeout 120000 -g |
| 10 | + |
| 11 | +# Install build dependencies for Oracle (node-oracledb needs them) |
| 12 | +RUN apt-get update \ |
| 13 | + && apt-get install -y python3 python3.11 libpython3.11-dev gcc g++ make cmake ca-certificates \ |
| 14 | + && rm -rf /var/lib/apt/lists/* |
| 15 | + |
| 16 | +# Install only Oracle and Postgres drivers |
| 17 | +RUN yarn install --prod && yarn cache clean |
| 18 | + |
| 19 | +# Production stage - minimal runtime |
| 20 | +FROM node:22-bookworm-slim |
| 21 | + |
| 22 | +ARG IMAGE_VERSION=custom |
| 23 | +ENV CUBEJS_DOCKER_IMAGE_VERSION=$IMAGE_VERSION |
| 24 | +ENV CUBEJS_DOCKER_IMAGE_TAG=minimal |
| 25 | + |
| 26 | +# Install runtime dependencies |
| 27 | +# Note: libpython3.11 is needed by @cubejs-backend/native even if not using .py configs |
| 28 | +RUN DEBIAN_FRONTEND=noninteractive \ |
| 29 | + && apt-get update \ |
| 30 | + && apt-get install -y --no-install-recommends libssl3 libpython3.11 \ |
| 31 | + && rm -rf /var/lib/apt/lists/* |
| 32 | + |
| 33 | +RUN yarn policies set-version v1.22.22 |
| 34 | + |
| 35 | +ENV NODE_ENV=production |
| 36 | + |
| 37 | +WORKDIR /cube |
| 38 | + |
| 39 | +# Copy built node_modules from builder |
| 40 | +COPY --from=builder /cube/node_modules ./node_modules |
| 41 | +COPY --from=builder /cube/package.json ./package.json |
| 42 | + |
| 43 | +# By default Node doesn't search in parent directory from /cube/conf |
| 44 | +ENV NODE_PATH=/cube/conf/node_modules:/cube/node_modules |
| 45 | +ENV PYTHONUNBUFFERED=1 |
| 46 | + |
| 47 | +# Create symlinks for CLI tools |
| 48 | +RUN ln -s /cube/node_modules/.bin/cubejs /usr/local/bin/cubejs |
| 49 | +RUN ln -s /cube/node_modules/.bin/cubestore-dev /usr/local/bin/cubestore-dev |
| 50 | + |
| 51 | +WORKDIR /cube/conf |
| 52 | + |
| 53 | +EXPOSE 4000 |
| 54 | + |
| 55 | +CMD ["cubejs", "server"] |
| 56 | + |
0 commit comments