question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

help with using craco with docker

See original GitHub issue

I am trying to get craco to work with my app which is running in a docker image. For some reason after I install craco I am getting an error when running it saying there is a webpack conflict. It’s putting webpack 4.43.0 and react scripts requires 4.42.0.

This is what I am getting when I run npm list webpack

/app # npm list webpack app@0.1.0 /app ±- craco@0.0.3 | -- webpack@4.43.0 – react-scripts@3.4.1 `-- webpack@4.42.0

does anyone know why this might be happening? Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
billtleecommented, Jun 4, 2020

Hi @gregoryforel, I am not very good at docker either. But I will try my best.

Here is my docker file for the client service:

FROM node:12-alpine
RUN apk --no-cache add --virtual builds-deps build-base python
RUN npm install -g nodemon
WORKDIR /app
COPY package.json /app/package.json
RUN npm install
COPY . /app
USER node
CMD ["npm", "run", "dev"]

In my package.json I have

"dev": "nodemon craco start"

Here is the client section in my docker-compose.yml

  clientv1:
    build:
      dockerfile: Dockerfile.dev
      context: ./app
    volumes:
      - /app/node_modules
      - ./app:/app
    tty: true

notice the last line tty: true. This is what made it work. However the terminal logging is acting a bit strange. Debugging is not as easy as before.

Hope this helps.

3reactions
billtleecommented, May 28, 2020

@yohanb I finally got it to work. I added tty: true to my docker file, then run docker-compose using a -d flag. Although the logging behavior is a bit annoying now so a bit harder to debug. The container wasn’t failing, npm just calls craco and as soon as it hands off to craco it considered it as a success and exit with an exit code of 0. If you guys figure out another way to get this to work, please let me know. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Craco with SemanticUI in Docker · Issue #96 - GitHub
Is there anybody trying to use Craco + ReactJS + Docker? I'm trying to follow these instructions: https://react.semantic-ui.com/theming.
Read more >
React App with craco doesn't start in docker-compose
The answer tells that, docker and webpack are in conflict to what is the internal container address. I changed my config.js file like...
Read more >
How to Add Docker to Create React App(CRA) + Run Unit Tests
In this tutorial, we'll be learning how to add a docker to Create-React App ... In Docker, the containers running share the host...
Read more >
Dockerize your React app - DEV Community ‍ ‍
I like putting react apps in containers! I created a docker compose files that runs create-react-app based apps loacally on Docker! dev.to/ ...
Read more >
How to Docker with React - Robin Wieruch
Before we can continue with Docker, we need to change one line in our package.json for starting the Webpack development server. The host...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found