2020-09-27 15:10:11 +03:00
|
|
|
# This Dockerfile can be used for docker-based deployments to platforms
|
|
|
|
# like Now or Moda, but it is currently _not_ used by our Heroku deployments
|
2021-02-03 22:50:29 +03:00
|
|
|
# It uses two multi-stage builds: `install` and the main build to keep the image size down.
|
2020-09-27 15:10:11 +03:00
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------
|
2021-05-25 01:40:50 +03:00
|
|
|
# BASE IMAGE
|
|
|
|
# --------------------------------------------------------------------------------
|
2022-01-24 20:35:52 +03:00
|
|
|
FROM node:16.13.2-alpine@sha256:f21f35732964a96306a84a8c4b5a829f6d3a0c5163237ff4b6b8b34f8d70064b as base
|
2021-05-25 01:40:50 +03:00
|
|
|
|
2022-01-24 20:35:52 +03:00
|
|
|
# This directory is owned by the node user
|
|
|
|
ARG APP_HOME=/home/node/app
|
2020-09-27 15:10:11 +03:00
|
|
|
|
2022-01-24 20:35:52 +03:00
|
|
|
# Make sure we don't run anything as the root user
|
|
|
|
USER node
|
|
|
|
|
|
|
|
WORKDIR $APP_HOME
|
2021-05-25 01:40:50 +03:00
|
|
|
|
|
|
|
|
|
|
|
# ---------------
|
|
|
|
# ALL DEPS
|
|
|
|
# ---------------
|
|
|
|
FROM base as all_deps
|
|
|
|
|
2022-01-24 20:35:52 +03:00
|
|
|
COPY --chown=node:node .npmrc ./
|
|
|
|
COPY --chown=node:node package*.json ./
|
2021-05-25 01:40:50 +03:00
|
|
|
|
|
|
|
RUN npm ci
|
|
|
|
|
2022-01-11 23:37:24 +03:00
|
|
|
# For Next.js v12+
|
2022-01-07 21:34:10 +03:00
|
|
|
# This the appropriate necessary extra for node:16-alpine
|
|
|
|
# Other options are https://www.npmjs.com/search?q=%40next%2Fswc
|
2022-01-11 23:37:24 +03:00
|
|
|
# RUN npm i @next/swc-linux-x64-musl --no-save
|
2022-01-07 21:34:10 +03:00
|
|
|
|
2021-05-25 01:40:50 +03:00
|
|
|
|
|
|
|
# ---------------
|
|
|
|
# PROD DEPS
|
|
|
|
# ---------------
|
|
|
|
FROM all_deps as prod_deps
|
|
|
|
|
|
|
|
RUN npm prune --production
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------
|
|
|
|
# BUILDER
|
|
|
|
# ---------------
|
|
|
|
FROM all_deps as builder
|
|
|
|
|
2020-09-27 15:10:11 +03:00
|
|
|
COPY stylesheets ./stylesheets
|
2021-05-25 01:40:50 +03:00
|
|
|
COPY pages ./pages
|
|
|
|
COPY components ./components
|
2020-09-27 15:10:11 +03:00
|
|
|
COPY lib ./lib
|
2021-05-25 01:40:50 +03:00
|
|
|
|
2021-12-17 19:51:47 +03:00
|
|
|
# One part of the build relies on this content file to pull all-products
|
2021-05-25 01:40:50 +03:00
|
|
|
COPY content/index.md ./content/index.md
|
|
|
|
|
|
|
|
COPY next.config.js ./next.config.js
|
|
|
|
COPY tsconfig.json ./tsconfig.json
|
2021-07-29 20:27:20 +03:00
|
|
|
COPY next-env.d.ts ./next-env.d.ts
|
2021-05-25 01:40:50 +03:00
|
|
|
|
2021-02-02 01:25:49 +03:00
|
|
|
RUN npm run build
|
2020-09-27 15:10:11 +03:00
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------
|
|
|
|
# MAIN IMAGE
|
2021-05-25 01:40:50 +03:00
|
|
|
# --------------------------------------------------------------------------------
|
2020-09-27 15:10:11 +03:00
|
|
|
|
2022-01-24 20:35:52 +03:00
|
|
|
FROM base as production
|
2020-09-27 15:10:11 +03:00
|
|
|
|
2021-05-25 01:40:50 +03:00
|
|
|
# Copy just our prod dependencies
|
2022-01-24 20:35:52 +03:00
|
|
|
COPY --chown=node:node --from=prod_deps $APP_HOME/node_modules $APP_HOME/node_modules
|
2020-09-27 15:10:11 +03:00
|
|
|
|
|
|
|
# Copy our front-end code
|
2022-01-24 20:35:52 +03:00
|
|
|
COPY --chown=node:node --from=builder $APP_HOME/.next $APP_HOME/.next
|
2020-09-27 15:10:11 +03:00
|
|
|
|
|
|
|
# We should always be running in production mode
|
|
|
|
ENV NODE_ENV production
|
|
|
|
|
2021-12-17 19:51:47 +03:00
|
|
|
# Whether to hide iframes, add warnings to external links
|
|
|
|
ENV AIRGAP false
|
|
|
|
|
|
|
|
# By default we typically don't want to run in clustered mode
|
|
|
|
ENV WEB_CONCURRENCY 1
|
|
|
|
|
|
|
|
# This makes sure server.mjs always picks up the preferred port
|
|
|
|
ENV PORT 4000
|
2021-02-02 01:25:49 +03:00
|
|
|
|
2020-09-27 15:10:11 +03:00
|
|
|
# Copy only what's needed to run the server
|
2022-01-05 18:42:53 +03:00
|
|
|
COPY --chown=node:node package.json ./
|
2020-09-27 15:10:11 +03:00
|
|
|
COPY --chown=node:node assets ./assets
|
|
|
|
COPY --chown=node:node includes ./includes
|
2021-12-17 19:51:47 +03:00
|
|
|
COPY --chown=node:node translations ./translations
|
|
|
|
COPY --chown=node:node content ./content
|
2020-09-27 15:10:11 +03:00
|
|
|
COPY --chown=node:node lib ./lib
|
|
|
|
COPY --chown=node:node middleware ./middleware
|
2021-02-02 01:25:49 +03:00
|
|
|
COPY --chown=node:node feature-flags.json ./
|
2021-12-17 19:51:47 +03:00
|
|
|
COPY --chown=node:node data ./data
|
2021-07-21 16:54:07 +03:00
|
|
|
COPY --chown=node:node next.config.js ./
|
2021-12-17 19:51:47 +03:00
|
|
|
COPY --chown=node:node server.mjs ./server.mjs
|
2020-09-27 15:10:11 +03:00
|
|
|
|
2021-11-13 21:17:47 +03:00
|
|
|
EXPOSE $PORT
|
|
|
|
|
2021-07-14 23:49:18 +03:00
|
|
|
CMD ["node", "server.mjs"]
|
2021-09-03 19:34:48 +03:00
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------------------
|
|
|
|
# MAIN IMAGE WITH EARLY ACCESS
|
|
|
|
# --------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
FROM production as production_early_access
|
|
|
|
|
|
|
|
COPY --chown=node:node content/early-access ./content/early-access
|
|
|
|
|
|
|
|
CMD ["node", "server.mjs"]
|