【发布时间】:2021-06-05 15:51:54
【问题描述】:
最近,我刚刚更改了我的 Nuxt 应用程序以支持 https,并使用如下简单的代码行。
nuxt.config.js
server: {
https: {
key: fs.readFileSync(path.resolve(__dirname, 'server.key')),
cert: fs.readFileSync(path.resolve(__dirname, 'server.cert'))
}
}
并且我尝试为这个应用构建 docker 镜像,当然,我已经排除了 server.key 和 server.cert。
Dockerfile
FROM node:12
WORKDIR /app
COPY . .
RUN npm install
RUN npm run build
ENV HOST 0.0.0.0
EXPOSE 3000
CMD ["npm", "run", "start"]
没想到,构建 Nuxt 应用程序需要运行 nuxt.config.js 文件,所以它输出跟随错误。
FATAL ENOENT: no such file or directory, open '/app/server.key'
at Object.openSync (fs.js:462:3)
at Object.readFileSync (fs.js:364:35)
at nuxt.config.js:80:24
at p (node_modules/jiti/dist/jiti.js:1:9442)
at Object.loadNuxtConfig (node_modules/@nuxt/config/dist/config.js:1054:15)
at loadNuxtConfig (node_modules/@nuxt/cli/dist/cli-index.js:338:32)
at NuxtCommand.getNuxtConfig (node_modules/@nuxt/cli/dist/cli-index.js:463:26)
at Object.run (node_modules/@nuxt/cli/dist/cli-build.js:90:30)
at NuxtCommand.run (node_modules/@nuxt/cli/dist/cli-index.js:413:22)
如何在不包含密钥文件的情况下对我的 Nuxt 应用程序进行 dockerize?我想在运行时使用 docker volume。
【问题讨论】:
标签: node.js docker https nuxt.js