[英]Can't Dockerize my simple typescript website
I am trying to get a Typescript project running in Docker.我正在尝试在 Docker 中运行一个 Typescript 项目。 I created the Docker file based on a tutorial but when I run it I get:
我根据教程创建了 Docker 文件,但是当我运行它时,我得到:
/usr/local/bin/docker-entrypoint.sh: 8: exec: .: Permission denied
/usr/local/bin/docker-entrypoint.sh: 8: exec: .: 权限被拒绝
I am not sure how to diagnosis this problem.我不知道如何诊断这个问题。
I can enter the container with我可以进入容器
docker run --rm -it d3ca97c88aec bash -il
and run the server with并运行服务器
npm start
I have no file called docker-entrypoint.sh and I didn't make one.我没有名为 docker-entrypoint.sh 的文件,我也没有创建。
I STRONGLY FEEL THIS IS BECAUSE TYPESCRIPT MAKES A BUILD FOLDER AND THAT BUILD FOLDER IS PERMISSIONED DIFFERENTLY.我强烈认为这是因为 TYPESCRIPT 生成了一个构建文件夹,并且该构建文件夹的权限不同。
Dockerfile文件
FROM node:12
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm install
# If you are building your code for production
# RUN npm ci --only=production
# Bundle app source
COPY . .
ENV COUCH_URL=NotSafeForStackOverflow
RUN npx tsc
EXPOSE 8080
CMD npx ts-node index.ts
{
"name": "express-react-app",
"version": "1.0.0",
"main": "index.js",
"repository": "",
"author": "",
"license": "",
"private": null,
"dependencies": {
"agentkeepalive": "^4.1.3",
"apollo-utilities": "^1.3.4",
"base64-arraybuffer": "^0.2.0",
"express": "^4.17.1",
"express-graphql": "^0.11.0",
"graphql": "^15.3.0",
"graphql-depth-limit": "^1.1.0",
"graphql-tag": "^2.11.0",
"graphql-type-json": "^0.3.2",
"i": "^0.3.6",
"merge-graphql-schemas": "^1.7.8",
"nano": "^8.2.2",
"node-webcrypto-ossl": "^2.1.1",
"npm": "^6.14.8",
"text-encoding": "^0.7.0",
"ts-node": "^9.0.0",
"typescript": "^3.7.4",
"uuid": "^8.3.0"
},
"scripts": {
"start": "npx ts-node index.ts",
"build": "npx tsc",
"dev": "nodemon --watch '**/*.ts' --exec 'ts-node' index.ts"
},
"devDependencies": {
"@types/express": "^4.17.7",
"@types/graphql": "^14.5.0",
"@types/node": "^14.6.3"
}
}
when you run CMD npx ts-node index.ts
it will overwrite default CMD [ "node" ]
当您运行
CMD npx ts-node index.ts
,它将覆盖默认CMD [ "node" ]
please refer link below to how to use node image :请参阅以下链接以了解如何使用节点图像:
https://github.com/nodejs/docker-node/blob/master/README.md#how-to-use-this-image
you shoud be able done by using docker-compose :你应该可以通过使用 docker-compose 来完成:
version: "2"
services:
node:
image: "node:8"
user: "node"
working_dir: /home/node/app
environment:
- NODE_ENV=production
volumes:
- ./:/home/node/app
expose:
- "8081"
command: "npm start"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.