API后端Dockerfile需要什么命令?

dm7nw8vv  于 2022-11-22  发布在  Docker
关注(0)|答案(1)|浏览(84)

我是创建Dockerfiles的新手,不知道用什么命令来启动API后端应用程序。我知道后端应用程序不使用Angular,启动它的命令不是“CMD ng serve --host 0.0.0.0“。
我附加了后端Dockerfile的代码,并提供了我在下面的Docker Desktop中运行容器时遇到的错误。
我看过Docker文档和节点命令,但不知道用什么命令来运行API后端。我做错了什么?

代码:

# using Node v10
FROM node:10

# Create app directory
WORKDIR /usr/src/lafs

# 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 . .

# Expose port 3000 outside container
EXPOSE 3000
# Command used to start application
CMD ng serve --host 0.0.0.0

我在Docker Desktop中收到的错误:

/bin/sh: 1: ng: not found
dauxcl2d

dauxcl2d1#

从您的original screenshot,看起来您有一个server目录。

FROM node:16 # 12 and older are EOL, 14 is in maintenance

WORKDIR /usr/src/lafs

EXPOSE 3000                  # assuming this is your server port

COPY server/package*.json .  # copy package.json and package-lock.json

RUN npm ci --only=production # install dependencies

COPY server .                # copy source code

CMD ["npm", "start"]         # start the Express server

相关问题