停止将Nodejs应用程序 - 复制从本地到WorkDir复制文件的错误

发布于 2025-02-08 10:37:51 字数 801 浏览 1 评论 0原文

我正在尝试扩展使用Firebase Cloud函数的Nodejs应用程序。

这就是我的项目目录的外观 -

”在此处输入图像描述

在不使用Docker的情况下运行时,我按照以下步骤启动服务器 -

  1. cd functions
  2. yarn serve - 此脚本存在于functions/poffage.json

现在,我想对此应用程序进行dockerize,我创建的dockerfile看起来像这样 -

FROM node:14-alpine

WORKDIR /api

COPY package*.json ./

RUN npm install

COPY . ./api

CMD ["npm", "run", "serve"]

当我使用它构建图像并运行容器时,执行失败会失败(我认为这是因为容器中缺少文件)

用于构建图像的命令 - docker build -t< my-image-name> ../功能

当我查看容器文件系统时,我看不到我在计算机上拥有的确切文件结构。

Dockerfile所需的所有更改是什么?

I am trying to Dockerize my Nodejs application which uses Firebase cloud functions.

This is what my project directory looks like -

enter image description here

When running without using Docker, I follow the following steps to start the server -

  1. cd functions
  2. yarn serve - this script is present in functions/package.json

Now I want to Dockerize this application, the Dockerfile which I created looks like this -

FROM node:14-alpine

WORKDIR /api

COPY package*.json ./

RUN npm install

COPY . ./api

CMD ["npm", "run", "serve"]

When I build an image using this and run the container, execution fails (I think it's because of missing files in the container)

Command used to build image -
docker build -t <my-image-name> ../functions

When I look into container file system I do not see the exact file structure which I have on my machine.

What are all the changes needed in Dockerfile?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文