From 0faf18ffe9a6b68b8e362231ca7b92b60c45b79f Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Fri, 4 Sep 2020 14:44:13 +0200 Subject: [PATCH 1/2] fix(lambda-nodejs): permission denied, mkdir '/.parcel-cache' When the project root (=`/asset-input` in the container) doesn't contain a lock file (npm or yarn), Parcel thinks that `/asset-input` is part of a monorepo with the root at `/` because the image installs Parcel at `/`. Ensure no lock file is created during installation of Parcel in the Docker image. --- packages/@aws-cdk/aws-lambda-nodejs/parcel/Dockerfile | 2 +- packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-lambda-nodejs/parcel/Dockerfile b/packages/@aws-cdk/aws-lambda-nodejs/parcel/Dockerfile index f3c90a65be151..40081228fd554 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/parcel/Dockerfile +++ b/packages/@aws-cdk/aws-lambda-nodejs/parcel/Dockerfile @@ -9,7 +9,7 @@ RUN npm install --global yarn # Install parcel 2 (fix the version since it's still in beta) # install at "/" so that node_modules will be in the path for /asset-input ARG PARCEL_VERSION=2.0.0-beta.1 -RUN cd / && npm install parcel@$PARCEL_VERSION +RUN cd / && npm install parcel@$PARCEL_VERSION --no-package-lock # Ensure all users can write to npm cache RUN mkdir /tmp/npm-cache && \ diff --git a/packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts b/packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts index bce8c270e99d3..b1d7690553e32 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts @@ -14,6 +14,15 @@ test('parcel is available', async () => { expect(proc.status).toEqual(0); }); +test('parcel is installed without a package-lock.json file', async () => { + const proc = spawnSync('docker', [ + 'run', 'parcel', + 'sh', '-c', + 'test ! -f /package-lock.json', + ]); + expect(proc.status).toEqual(0); +}); + test('can npm install with non root user', async () => { const proc = spawnSync('docker', [ 'run', '-u', '1000:1000', From eda84df18adc519c90dcbb6cee4cafb057d33f74 Mon Sep 17 00:00:00 2001 From: Jonathan Goldwasser Date: Mon, 7 Sep 2020 11:51:24 +0200 Subject: [PATCH 2/2] add github issue in comment --- packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts b/packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts index b1d7690553e32..dfb8d07b0fb4a 100644 --- a/packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts +++ b/packages/@aws-cdk/aws-lambda-nodejs/test/docker.test.ts @@ -15,6 +15,9 @@ test('parcel is available', async () => { }); test('parcel is installed without a package-lock.json file', async () => { + // We don't want a lock file at / to prevent Parcel from considering that /asset-input + // is part of a monorepo. + // See https://github.com/aws/aws-cdk/pull/10039#issuecomment-682738396 const proc = spawnSync('docker', [ 'run', 'parcel', 'sh', '-c',