2

I have a react app which after some times I managed to build with docker. Everything here is done on my local machine(windows 10 pro).

I have the following docker file:

# build environment
FROM node:12.13.0-alpine as build
WORKDIR /app
# ENV PATH /app/node_modules/.bin:$PATH
COPY package.json yarn.lock ./
RUN npm install --silent
COPY . /app
RUN npm run build

# production environment
FROM nginx:1.16.0-alpine
COPY --from=build /app/build /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

Im still new to this and I might be wrong but after this build via:

docker build . -t myapp

and run it:

docker run -p 8080:80 myapp

visiting http://localhost:8080/ and expecting my files via dev tools i still see the following:

enter image description here

my files are still exposed.

What am I missing? Thought that the production build would not show everything?

CodingLittle
  • 1,761
  • 2
  • 17
  • 44
  • Did you try this? https://stackoverflow.com/questions/51984146/how-to-disable-source-maps-for-react-js-application – Justin Lessard Nov 04 '19 at 21:44
  • @JustinLessard thanks for the input. I tried the following: "build": "GENERATE_SOURCEMAP=false && react-scripts build", does it work with the react-creatapp scripts or am I missing some logic? – CodingLittle Nov 04 '19 at 21:50
  • 1
    It should. [Yon can also](https://github.com/mars/create-react-app-buildpack/issues/59) create a file name `.env` in your project root and write `GENERATE_SOURCEMAP=false` – Justin Lessard Nov 04 '19 at 21:54
  • @JustinLessard Thanks m8. I really think this is a question worthy keeping even though I got the answer in the comments. Could you add your suggestion above as an answer. – CodingLittle Nov 04 '19 at 21:57

1 Answers1

2

You need to remove the source maps.

From this github issue

We can now disable sourcemap with putting below setting in a .env file (at the root of the project): GENERATE_SOURCEMAP=false

Justin Lessard
  • 10,804
  • 5
  • 49
  • 61