Switch back to using specific node versions

+ added description block encouraging and reminding people to set the specific version their application needs.
This commit is contained in:
2019-12-07 12:07:09 +09:00
parent 8370c7f0bc
commit b170e9ce01
2 changed files with 22 additions and 10 deletions

View File

@@ -1,6 +1,10 @@
# Step 1: Initial build using the `yarn build` command
####################################################
FROM node:latest as build
#################################################################
# Step 1: Initial build using the `yarn build` command #
#################################################################
# Note: Make sure the right version of node your application #
# requires is set here and in all other build steps. #
#################################################################
FROM node:13 as build
# Prepare the build directory
RUN mkdir -p /opt/build;
@@ -18,9 +22,13 @@ COPY [ "package.json", "yarn.lock", "tsconfig.json", "./" ]
RUN yarn install --no-progress && yarn build
# Step 2: Fetch production-only dependencies
####################################################
FROM node:latest as dependencies
#################################################################
# Step 2: Fetch production-only dependencies #
#################################################################
# Note: Make sure the right version of node your application #
# requires is set here and in all other build steps. #
#################################################################
FROM node:13 as dependencies
# Set environment to production
ENV NODE_ENV='production'
@@ -34,9 +42,13 @@ COPY --from=build [ "/opt/build/package.json", "/opt/build/yarn.lock", "./" ]
RUN yarn install --production=true --no-progress
# Step 3: Build done, create the deployable/runnable image step
####################################################
FROM node:slim as release
#################################################################
# Step 3: Build done, create the deployable/runnable image step #
#################################################################
# Note: Make sure the right version of node your application #
# requires is set here and in all other build steps. #
#################################################################
FROM node:13-slim as release
# Set environment to production
ENV NODE_ENV='production'

View File

@@ -8,7 +8,7 @@ There are several benefits to this, but one of the bigger ones I would say is th
## Node versions
- 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.
- 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.
- 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.
## Prerequisites