无法在本地运行dockerfile

问题描述 投票:0回答:1

我正在尝试在本地运行 dockerfile(Node TypeScript 上的项目)

docker文件

FROM node:20-alpine

EXPOSE 5000
MAINTAINER Some Dev

RUN mkdir /app
WORKDIR /app

COPY ./backend/* /app

RUN npm i

CMD ["npm","start"]

但我有一个问题错误 TS18003:在配置文件“/app/tsconfig.json”中找不到输入。指定的“包含”路径为“[“./src/”,“./src/**/.ts”,“./src/.ts”]',“排除”路径为“[”./距离”]'。

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2021",                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
    "module": "commonJS",                                /* Specify what module code is generated. */
    "moduleResolution": "node",                          /* Specify how TypeScript looks up a file from a given module specifier. */
    "rootDir": "./src",/* Specify the root folder within your source files. */
    "outDir": "./dist",                                  /* Specify an output folder for all emitted files. */
    "esModuleInterop": true,                             /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
    "allowSyntheticDefaultImports": true,                /* Allow 'import x from y' when a module doesn't have a default export. */
    "removeComments": true,                              /* Disable emitting comments. */
    "noImplicitAny": true,                               /* Enable error reporting for expressions and declarations with an implied 'any' type. */
    "noUnusedLocals": true,                              /* Enable error reporting when local variables aren't read. */
    "skipLibCheck": true
  },
  "include": [
    "./src/",
    "./src/**/*.ts",
    "./src/*.ts"
  ],
  "exclude": [
    "./dist"
  ]
}

我的文件夹 我的文件夹

在包含、排除中尝试了一些不同的事情。看到建议添加空 ts 文件并创建,但没有任何变化。重启IDE(IntelliJ idea)。

node.js typescript docker dockerfile localhost
1个回答
0
投票

/backend
的子目录不会被复制到
/app
中。将
COPY ./backend/* /app
更改为
COPY ./backend /app
。 * 仅复制文件夹内的文件,而不复制子目录。

© www.soinside.com 2019 - 2024. All rights reserved.