Created
June 18, 2019 17:54
-
-
Save msreekm/a141725bb8e98649b3718a1ed6a94d0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---- 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
@derakhshanfar you're Dockerfile is really interesting. Can you provide a sample docker command to build as well as a sample oh how it might be used as part of a compose file?