简体   繁体   中英

Issues with creating a docker container for react front end with yarn

Context: I'm currently working on a project with a Java backend and React frontend. I am trying to get the react front end working in a docker container (it currently runs if I just run yarn start). I am writing a Dockerfile which I believe I would build to then provide an image that I can run.

I try to build the docker file using docker build ./ but run into the following in error:

=> ERROR [deps 4/6] RUN yarn install                                                                                                           105.6s
------                                                                                                                                                 
 > [deps 4/6] RUN yarn install:                                                                                                                        
#10 3.031 yarn install v1.12.1                                                                                                                         
#10 3.693 [1/4] Resolving packages...                                                                                                                  
#10 9.308 [2/4] Fetching packages...                                                                                                                   
#10 42.12 info There appears to be trouble with your network connection. Retrying...                                                                   
#10 105.0 error autoprefixer@10.2.5: The engine "node" is incompatible with this module. Expected version "^10 || ^12 || >=14". Got "11.1.0"
#10 105.0 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
#10 105.0 error Found incompatible module

My docker file is as follows:

FROM node:11.1.0-alpine AS node_base

FROM node_base as deps
WORKDIR /ProjectFrontEnd
COPY package.json .
COPY yarn.lock .
RUN yarn install

COPY . .

# FROM node_base as build
# WORKDIR /ProjectFrontEnd
# COPY --from=deps /ProjectFrontEnd/node_modules /ProjectFrontEnd/node_modules
# COPY . /ProjectFrontEnd
# Expose port
EXPOSE 3000

RUN yarn build

# FROM scratch AS ui
# COPY --from=build /ProjectFrontEnd/ /ProjectFrontEnd/

#start the app
CMD [ "yarn start" ]

I'm quite new to this but would appreciate any help/guidance. Thanks in advance.

Question answered by Brian Thompson in the comments. The error syntax made it unclear that it was referring to the version. I looked up the docker version and found the latest valid one which was 16.13.0 and used this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM