Skip to content

Commit b170e9c

Browse files
committed
Switch back to using specific node versions
+ added description block encouraging and reminding people to set the specific version their application needs.
1 parent 8370c7f commit b170e9c

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

Dockerfile

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# Step 1: Initial build using the `yarn build` command
2-
####################################################
3-
FROM node:latest as build
1+
#################################################################
2+
# Step 1: Initial build using the `yarn build` command #
3+
#################################################################
4+
# Note: Make sure the right version of node your application #
5+
# requires is set here and in all other build steps. #
6+
#################################################################
7+
FROM node:13 as build
48

59
# Prepare the build directory
610
RUN mkdir -p /opt/build;
@@ -18,9 +22,13 @@ COPY [ "package.json", "yarn.lock", "tsconfig.json", "./" ]
1822
RUN yarn install --no-progress && yarn build
1923

2024

21-
# Step 2: Fetch production-only dependencies
22-
####################################################
23-
FROM node:latest as dependencies
25+
#################################################################
26+
# Step 2: Fetch production-only dependencies #
27+
#################################################################
28+
# Note: Make sure the right version of node your application #
29+
# requires is set here and in all other build steps. #
30+
#################################################################
31+
FROM node:13 as dependencies
2432

2533
# Set environment to production
2634
ENV NODE_ENV='production'
@@ -34,9 +42,13 @@ COPY --from=build [ "/opt/build/package.json", "/opt/build/yarn.lock", "./" ]
3442
RUN yarn install --production=true --no-progress
3543

3644

37-
# Step 3: Build done, create the deployable/runnable image step
38-
####################################################
39-
FROM node:slim as release
45+
#################################################################
46+
# Step 3: Build done, create the deployable/runnable image step #
47+
#################################################################
48+
# Note: Make sure the right version of node your application #
49+
# requires is set here and in all other build steps. #
50+
#################################################################
51+
FROM node:13-slim as release
4052

4153
# Set environment to production
4254
ENV NODE_ENV='production'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ There are several benefits to this, but one of the bigger ones I would say is th
88

99
## Node versions
1010

11-
- The template uses `node:latest`, but normally I set a specific node version to ensure compatibility with whatever application I am working with/on. You might want to set a specific version in all three phases, or just stick with `latest` if you like.
11+
- The template uses `node:13`, but be sure to update this to whatever specific version of node your application requires. Make sure to set this accordingly in all three build steps, too.
1212
- The final stage (which actually runs your application) uses the `node:slim` image, a lighter version that only contains whatever is required to actually run Node. If your application or specific packages used is having issues running in this environment, consider changing the final phase to use `node:alpine` instead. Using the full image here would mean it still will come with tools like NPM and Yarn pre-installed, which is not ideal. Please refer to the [official node image documentation](https://hub.docker.com/_/node/) for more information.
1313

1414
## Prerequisites

0 commit comments

Comments
 (0)