Docker 打包 NuxtJS

目录

Docker 镜像加速(Linux 为例)

创建 /etc/docker/daemon.json 的配置文件

{
  "registry-mirrors": ["https://registry.docker-cn.com", "https://9zh8kwqg.mirror.aliyuncs.com"]
}
systemctl restart docker

编写 dockerfle

FROM node:10.17.0
MAINTAINER wolfx
ENV NODE_ENV=production
ENV HOST 0.0.0.0
RUN mkdir -p /app
COPY ./ /app
WORKDIR /app
EXPOSE 3000
# RUN npm config set registry https://registry.npm.taobao.org
RUN npm config set registry http://127.0.0.1:8889/repository/npm-proxy/
RUN npm install
RUN npm run build
CMD ["npm", "start"]

如何构建

# build image
docker build -t nuxt-demo ./

如何导出

docker save -o myimages.gz nuxt-demo

如何导入

docker load -i myimages.gz

如何运行

# serve at localhost:8080
docker run -dt -p 8080:3000 nuxt-demo