Hi i published a library in github npm registry to be used for extensions. However when I tried putting .npmrc file with the correct secret into a custom dockerfile for directus I can’t get it to work. Should it be in the root directory for directus?
/directus directory?
something like this
# --- Build Stage ---
FROM directus/directus:11.12.0 AS build
WORKDIR /directus
# Switch to root to install pnpm, as it's used by Directus internally
USER root
RUN npm install -g pnpm
# Switch back to the node user (default user in directus image)
USER node
# Copy package.json and .npmrc
COPY package.json .npmrc ./
# Install dependencies using build secret for secure access to the private registry
# The --secret flag requires BuildKit to be enabled
RUN --mount=type=secret,id=npmrc,dst=.npmrc pnpm install --prod
# Remove the .npmrc file after installation for security
RUN rm -f .npmrc
# Copy the rest of your application files, including extensions
COPY . .
# If you have custom extensions built, ensure they are compiled or copied correctly.
# The `pnpm install` above should handle installing the extension dependencies.
# --- Final Stage (Optional but Recommended for a cleaner final image) ---
# Use a fresh Directus image and copy only necessary files from the build stage
FROM directus/directus:11.12.0
WORKDIR /directus
# Copy installed node_modules and other project files from the build stage
COPY --from=build /directus/node_modules ./node_modules
COPY --from=build /directus/package.json ./package.json
COPY --from=build /directus/src ./src
COPY --from=build /directus/extensions ./extensions
COPY --from=build /directus/uploads ./uploads
# Copy other necessary files/folders like public, etc.
# Expose port and start Directus (default behavior of directus/directus image)
EXPOSE 8055
CMD ["directus", "start"]