0

我试图使用Dockerfile在 DigitalOcean droplet 中部署我的自定义 Saleor。对于生产环境 Dockerfile 是

FROM node:10 as builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
ARG API_URI
ENV API_URI ${API_URI:-http://localhost:8000/graphql/}
RUN API_URI=${API_URI} npm run build

FROM nginx:stable
WORKDIR /app
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist/ /app/

对于开发环境 Dockerfile.dev 是

FROM node:10

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
ARG APP_MOUNT_URI
ARG API_URI
ARG STATIC_URL
ENV API_URI ${API_URI:-http://localhost:8000/graphql/}
ENV APP_MOUNT_URI ${APP_MOUNT_URI:-/dashboard/}
ENV STATIC_URL ${STATIC_URL:-/dashboard/}

EXPOSE 9000
CMD npm start -- --host 0.0.0.0

我可以使用 Dockerfile.dev 进行部署,但不能使用 Dockerfile 进行生产部署。最终出现以下错误

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! saleor-site@2.10.4 build: `webpack -p`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the saleor-site@2.10.4 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-08-23T18_40_53_645Z-debug.log
ERROR: Service 'storefront' failed to build: The command '/bin/sh -c API_URI=${API_URI} npm run build' returned a non-zero code: 2
4

0 回答 0