我一直有一个问题,我在哪里得到了错误:Cannot find module '/mfa/main.js'
。
但是,main.js
位于/mfa/dist/apps/api
的内部
这是我拥有的Dockerfile的最新配置:
FROM node:14
WORKDIR /mfa/
COPY package.json .
COPY decorate-angular-cli.js .
COPY yarn.lock .
# Configure NPM with the group access token
ENV GROUP_NPM_TOKEN="asdfghjkiuy"
RUN npm config set @my-web:registry http://git.hoosiers.com/api/v4/packages/npm
RUN npm config set //git.hoosiers.com/api/v4/packages/npm/:_authToken=${GROUP_NPM_TOKEN}
RUN npm config set //git.hoosiers.com/api/v4/packages/projects/:_authToken=${GROUP_NPM_TOKEN}
RUN yarn add typescript
RUN yarn install --frozen-lockfile
COPY ./dist .
CMD ["node", "apps/api/main.js"]
所以现在docker run <image-hash>
运行得很好,但是当我尝试docker-compose up
时,我再次得到了Cannot find module '/mfa/main.js'
。
这是我的docker-compose.yml
文件:
version: '3.9'
services:
web-app:
build:
context: .
dockerfile: mostly-failed-apps.Dockerfile
ports:
- "3000:3000"
发布于 2022-08-16 18:59:37
您已经将WORKDIR定义为/mfa,并在api/api/ main.js中执行main.js
对于拷贝来说,写/mfa/您只需写点(.)并不是必须的。因为你的世界
`
FROM node:14
# Go on /mfa if is dosen't exist WORKDIR create it and go in
WORKDIR /mfa/
# Copy of package.json where we are so we are with the dot so in /mfa/ it's the same for all copy
COPY package.json .
COPY decorate-angular-cli.js .
COPY yarn.lock .
# Configure NPM with the group access token
ENV GROUP_NPM_TOKEN="token"
RUN npm config set @my-web:registry http://git.hoosiers.com/api/v4/packages/npm
RUN npm config set //git.hoosiers.com/api/v4/packages/npm/:_authToken=${GROUP_NPM_TOKEN}
RUN npm config set //git.hoosiers.com/api/v4/packages/projects/:_authToken=${GROUP_NPM_TOKEN}
RUN yarn add typescript
RUN yarn install --frozen-lockfile
COPY ./dist .
# You have create your docker with /mfa/ so you need to excute it in /mfa/
CMD ["node", "/mfa/dist/apps/api/main.js"]
`
https://stackoverflow.com/questions/73378951
复制相似问题