Skip to content

Commit 9f498f1

Browse files
authored
Split 'npm install' and source copy (+ 'npm run build') stages (#3371)
1 parent b9f9b53 commit 9f498f1

File tree

5 files changed

+37
-17
lines changed

5 files changed

+37
-17
lines changed

Diff for: src/Azure.Functions.Cli/StaticResources/Dockerfile.node14

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ FROM mcr.microsoft.com/azure-functions/node:4-node14
55
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
66
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
77

8-
COPY . /home/site/wwwroot
8+
WORKDIR /home/site/wwwroot
99

10-
RUN cd /home/site/wwwroot && \
11-
npm install
10+
# Copy package.json and install packages before copying the rest of the code to enable caching
11+
COPY package.json package.json
12+
RUN npm install
13+
14+
# Copy the rest of the code
15+
COPY . .

Diff for: src/Azure.Functions.Cli/StaticResources/Dockerfile.node16

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ FROM mcr.microsoft.com/azure-functions/node:4-node16
55
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
66
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
77

8-
COPY . /home/site/wwwroot
8+
WORKDIR /home/site/wwwroot
99

10-
RUN cd /home/site/wwwroot && \
11-
npm install
10+
# Copy package.json and install packages before copying the rest of the code to enable caching
11+
COPY package.json package.json
12+
RUN npm install
13+
14+
# Copy the rest of the code
15+
COPY . .

Diff for: src/Azure.Functions.Cli/StaticResources/Dockerfile.node18

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ FROM mcr.microsoft.com/azure-functions/node:4-node18
55
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
66
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
77

8-
COPY . /home/site/wwwroot
8+
WORKDIR /home/site/wwwroot
99

10-
RUN cd /home/site/wwwroot && \
11-
npm install
10+
# Copy package.json and install packages before copying the rest of the code to enable caching
11+
COPY package.json package.json
12+
RUN npm install
13+
14+
# Copy the rest of the code
15+
COPY . .

Diff for: src/Azure.Functions.Cli/StaticResources/Dockerfile.typescript

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ FROM mcr.microsoft.com/azure-functions/node:4-node16
55
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
66
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
77

8-
COPY . /home/site/wwwroot
8+
WORKDIR /home/site/wwwroot
99

10-
RUN cd /home/site/wwwroot && \
11-
npm install && \
12-
npm run build
10+
# Copy package.json and install packages before copying the rest of the code to enable caching
11+
COPY package.json package.json
12+
RUN npm install
13+
14+
# Copy the rest of the code
15+
COPY . .
16+
RUN npm run build

Diff for: src/Azure.Functions.Cli/StaticResources/Dockerfile.typescript.node18

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ FROM mcr.microsoft.com/azure-functions/node:4-node18
55
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
66
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
77

8-
COPY . /home/site/wwwroot
8+
WORKDIR /home/site/wwwroot
99

10-
RUN cd /home/site/wwwroot && \
11-
npm install && \
12-
npm run build
10+
# Copy package.json and install packages before copying the rest of the code to enable caching
11+
COPY package.json package.json
12+
RUN npm install
13+
14+
# Copy the rest of the code
15+
COPY . .
16+
RUN npm run build

0 commit comments

Comments
 (0)