Forked from praveenweb/6.multi-stage-production-node.Dockerfile
Last active
March 2, 2018 11:55
-
-
Save lex111/e6309d5588ccaeb44ca15c81ff691dd1 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
# ---- Базовый Node ---- | |
FROM node:carbon AS base | |
# Создать директорию app | |
WORKDIR /app | |
# ---- Зависимости ---- | |
FROM base AS dependencies | |
# Используется символ подстановки для копирования как package.json, так и package-lock.json | |
COPY package*.json ./ | |
# Установить зависимости приложения, включая предназначенные для разработки ('devDependencies') | |
RUN npm install | |
# ---- Скопировать файлы/билд ---- | |
FROM dependencies AS build | |
WORKDIR /app | |
COPY src /app | |
# Собрать статические файлы react/vue/angular | |
# RUN npm run build | |
# --- Выпуск, используя Alpine ---- | |
FROM node:8.9-alpine AS release | |
# Создать директорию app | |
WORKDIR /app | |
# Необязательно | |
# RUN npm -g install serve | |
COPY --from=dependencies /app/package.json ./ | |
# Установить зависимости приложения | |
RUN npm install --only=production | |
COPY --from=build /app ./ | |
# CMD ["serve", "-s", "dist", "-p", "8080"] | |
CMD ["node", "server.js"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment