Build fails with custom .nprmrc for installing private npm packages
jeremyccranePRO
10 months ago
Attempting to add a private npm package to my Dockerfile build. Cannot get the app to use the .npmrc file to download using my Github authtoken.
Figured I would throw it up here in case it's a simple misunderstanding on Railway setup.
I have tried all suggestions from the Railway documentation and the Help Station, as well as additional help from the web from other individuals who have had to install custom packages using Docker.
In addition, here are some of what I have tried that have not worked:
COPY .npmrc /root/.npmrc
USER root
RUN echo "@nessprim:registry=https://npm.pkg.github.com/" >>/root/.npmrc
RUN echo "//npm.pkg.github.com/:_authToken=[redacted]" >>/root/.npmrc
USER node
COPY .npmrc $APP_SOURCE_FOLDER/.npmrc
USER root
RUN echo "@nessprim:registry=https://npm.pkg.github.com/" >>$APP_SOURCE_FOLDER/.npmrc
RUN echo "//npm.pkg.github.com/:_authToken=[redacted]" >>$APP_SOURCE_FOLDER/.npmrc
USER node
USER root
RUN --mount=type=cache,id=s/5d402589-f23a-4db8-b7b5-202ca2010017-/root/npm-cache,target=/root/.npm \
npm install --ignore-engines
USER node
2 Replies
jeremyccranePRO
10 months ago
RESOLVED!!!! Here is my Dockerfile if anyone else runs into this:
# The tag here should match the Meteor version of your app, per .meteor/release
FROM geoffreybooth/meteor-base:2.13.3
# Copy app package.json and package-lock.json into container
COPY ./package*.json $APP_SOURCE_FOLDER/
USER root
RUN echo "@nessprim:registry=https://npm.pkg.github.com/" >>/root/.npmrc
RUN echo "//npm.pkg.github.com/:_authToken=[redacted]" >>/root/.npmrc
RUN bash $SCRIPTS_FOLDER/build-app-npm-dependencies.sh
# Copy app source into container
COPY . $APP_SOURCE_FOLDER/
RUN bash $SCRIPTS_FOLDER/build-meteor-bundle.sh
COPY .npmrc /root/.npmrc
# Use the specific version of Node expected by your Meteor release, per https://docs.meteor.com/changelog.html; this is expected for Meteor 1.9
FROM node:14-alpine
ENV APP_BUNDLE_FOLDER /opt/bundle
ENV SCRIPTS_FOLDER /docker
# Install OS build dependencies, which we remove later after we’ve compiled native Node extensions
RUN apk --no-cache --virtual .node-gyp-compilation-dependencies add \
g++ \
make \
python3 \
# And runtime dependencies, which we keep
&& apk --no-cache add \
bash \
ca-certificates
# Copy in entrypoint
COPY --from=0 $SCRIPTS_FOLDER $SCRIPTS_FOLDER/
# Copy in app bundle
COPY --from=0 $APP_BUNDLE_FOLDER/bundle $APP_BUNDLE_FOLDER/bundle/
RUN bash $SCRIPTS_FOLDER/build-meteor-npm-dependencies.sh --build-from-source \
&& apk del .node-gyp-compilation-dependencies
# Start app
ENTRYPOINT ["/docker/entrypoint.sh"]
CMD ["node", "main.js"]
Status changed to Solved railway[bot] • 10 months ago