我对这个 Docker 世界还很陌生,我正在尝试将图像(nodejs-typescript 服务)从 aws ECR 部署到 aws ECS,但是当我在集群内创建服务时,会出现此错误,并且任务永远不会运行:
exec /usr/local/bin/docker-entrypoint.sh: exec format error
Run Code Online (Sandbox Code Playgroud)
我的 Dockerfile 如下所示:
FROM node:lts-alpine
WORKDIR /usr/app
COPY package*.json ./
COPY tsconfig*.json ./
RUN yarn install --quiet
RUN yarn global add pm2
COPY . .
RUN yarn build
CMD ["pm2-runtime", "build/src/localServer.js"]
Run Code Online (Sandbox Code Playgroud)
当我构建映像并运行它时,它在我的电脑上运行良好:
FROM node:lts-alpine
WORKDIR /usr/app
COPY package*.json ./
COPY tsconfig*.json ./
RUN yarn install --quiet
RUN yarn global add pm2
COPY . .
RUN yarn build
CMD ["pm2-runtime", "build/src/localServer.js"]
Run Code Online (Sandbox Code Playgroud)
任务定义在 Linux/X86_64 上运行。
有什么建议或提示可以找出问题所在吗?谢谢!
编辑:当我像这样向 Dockerfile …
我有一个打字稿没有正确读取我的返回类型的问题。我正在定义一个返回类型为something | null. 打字稿所做的是只读取something类型,忽略空值,当我调用函数时可以返回空值。
function nullornot(): null | string { // here is says it returns null | string
return null
}
const response = nullornot() // but here is says it returns string
Run Code Online (Sandbox Code Playgroud)
我的 tsconfig.json 文件
{
"extends": "./tsconfig.paths.json",
"compilerOptions": {
"typeRoots": ["node_modules/@types", "src/@types"],
"allowSyntheticDefaultImports": true,
"lib": ["ESNext"],
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"sourceMap": true,
"target": "ESNext",
"outDir": "lib"
},
"files": ["src/@types/graphql.d.ts"],
"include": ["src/**/*.ts"],
"exclude": [
"node_modules/**/*",
".serverless/**/*",
".webpack/**/*",
"_warmup/**/*",
".vscode/**/*"
] …Run Code Online (Sandbox Code Playgroud) 我正在尝试访问getPlaces()应该位于StandaloneSearchBox组件中的函数react-google-maps/api。在文档和其他示例中,我们以这种方式使用它:
function Map() {\n\n // does not work.\n // Error -> \'this\' implicitly has type \'any\' because it does not have a type \n // annotation.ts(2683)\n // index.tsx(22, 10): An outer value of \'this\' is shadowed by this container.\n const onPlacesChanged = () => console.log(this.searchBox.getPlaces());\n\n return (\n <LoadScript\n googleMapsApiKey="YOUR-API-KEY"\n libraries={places}\n >\n <GoogleMap\n mapContainerStyle={containerStyle}\n center={center}\n zoom={zoom}\n >\n { /* Child components, such as markers, info windows, etc. */}\n <>\n <StandaloneSearchBox onPlacesChanged={onPlacesChanged} >\n …Run Code Online (Sandbox Code Playgroud) node.js ×2
amazon-ecs ×1
aws-fargate ×1
docker ×1
google-maps ×1
javascript ×1
reactjs ×1
typescript ×1
webpack ×1