Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ivawzh/b9cd8b433068d1cab2a9a9dbfe52997f to your computer and use it in GitHub Desktop.
Save ivawzh/b9cd8b433068d1cab2a9a9dbfe52997f to your computer and use it in GitHub Desktop.
# ---- Base Node ----
FROM mhart/alpine-node:10 AS base
# install node
RUN apk add --no-cache nodejs-current
# set working directory
WORKDIR /root/nextApp
# copy project file
COPY package.json .
COPY tsconfig.server.json .
COPY .npmrc .
COPY _build/staging.env ./.env
#
# ---- Dependencies ----
FROM base AS dependencies
# install node packages
RUN npm set progress=false && npm config set depth 0
RUN npm config set "@fortawesome:registry" https://npm.fontawesome.com/ && \
npm config set "//npm.fontawesome.com/:_authToken" XXXXXX yarn global add typescript
# install global packages
RUN npm install -g rimraf typescript
# install only production node_modules
RUN npm install --only=production
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN npm install
#
# ---- Test ----
# run linters and tests
FROM dependencies AS test
COPY . .
RUN npm run lint
#
# ---- Release ----
FROM base AS release
# copy production node_modules
COPY --from=dependencies /root/nextApp/prod_node_modules ./node_modules
# copy app sources
COPY . .
RUN npm run ci-build
# expose port and define CMD
EXPOSE 1610
CMD npm run start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment