Optional .npmrc to support private NPM registry

This commit is contained in:
Fabian Chong
2020-11-26 18:28:50 +08:00
committed by Joel Low
parent 05f3ca491e
commit fe5c6a7727
3 changed files with 7 additions and 2 deletions
@@ -34,11 +34,15 @@ export default async (cmd: Command) => {
const pkgPath = paths.resolveTarget(PKG_PATH);
const pkg = await fs.readJson(pkgPath);
const appConfigs = await findAppConfigs();
const npmrc = fs.existsSync(paths.resolveTargetRoot('.npmrc'))
? ['.npmrc']
: [];
const tempDistWorkspace = await createDistWorkspace([pkg.name], {
buildDependencies: Boolean(cmd.build),
files: [
'package.json',
'yarn.lock',
...npmrc,
...appConfigs,
{ src: paths.resolveTarget('Dockerfile'), dest: 'Dockerfile' },
],
@@ -8,7 +8,7 @@
"scripts": {
"start": "yarn workspace app start",
"build": "lerna run build",
"build-image": "yarn workspace backend build-image",
"build-image": "yarn workspace backend build-image --build-arg NPM_TOKEN",
"tsc": "tsc",
"tsc:full": "tsc --skipLibCheck false --incremental false",
"clean": "backstage-cli clean && lerna run clean",
@@ -1,11 +1,12 @@
FROM node:12-buster
ARG NPM_TOKEN
WORKDIR /usr/src/app
# Copy repo skeleton first, to avoid unnecessary docker cache invalidation.
# The skeleton contains the package.json of each package in the monorepo,
# and along with yarn.lock and the root package.json, that's enough to run yarn install.
ADD yarn.lock package.json skeleton.tar ./
ADD .npmrc* yarn.lock package.json skeleton.tar ./
RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)"