2

i cant seem to find what causes this, This is the result in an incognito window: enter image description here and i have this errors in my console:

main.83e12943.chunk.js:1 Failed to load resource: the server responded with a status of 404 ()
main.5f361e03.chunk.css:1 Failed to load resource: the server responded with a status of 404 ()
logo.5d5d9eef.svg:1 Failed to load resource: the server responded with a status of 404 ()
DevTools failed to load SourceMap: Could not load content for https://ticketing.dev/static/js/2.a925df73.chunk.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
DevTools failed to load SourceMap: Could not load content for https://ticketing.dev/static/css/main.5f361e03.chunk.css.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

I am using the latest create react app version and this is my Docker file:

# build environment
FROM node:13.12.0-alpine as build
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json ./
COPY package-lock.json ./
RUN npm ci --silent
RUN npm install react-scripts@3.4.1 -g --silent
COPY . ./
RUN npm run build

# production environment
FROM nginx:stable-alpine
COPY --from=build /app/build /usr/share/nginx/html
# new
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 3000
CMD ["nginx", "-g", "daemon off;"]

my nginx.conf inspired from this post: https://mherman.org/blog/dockerizing-a-react-app/

server {

  listen 3000;

  location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    try_files $uri $uri/ /index.html;
  }

  error_page   500 502 503 504  /50x.html;

  location = /50x.html {
    root   /usr/share/nginx/html;
  }

}

This is Kubernetes Deployment/Service:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/component: service
  name: client-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: client
  template:
    metadata:
      labels:
        app.kubernetes.io/component: service
        app: client
    spec:
      containers:
        - name: client
          image: asia.gcr.io/udemy-ticketing-dev-285506/client
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/component: service
  name: client-srv
spec:
  ports:
    - name: client
      protocol: TCP
      port: 3000
      targetPort: 3000
  selector:
    app: client
  type: NodePort

and lastly is my ingress service:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
  rules:
    - host: ticketing.dev
      http:
        paths:
          - path: /api/users/?(.*)
            backend:
              serviceName: auth-srv
              servicePort: 3000
          - path: /?(.*)
            backend:
              serviceName: client-srv
              servicePort: 3000

where did i go wrong?

gpbaculio
  • 5,693
  • 13
  • 60
  • 102
  • Could you try to add another path in your ingress with `path: /static`? If that won´t work then I assume this might be a devtools issue. take a look [here](https://stackoverflow.com/questions/61205390/devtools-failed-to-load-sourcemap-could-not-load-content) or [here](https://stackoverflow.com/questions/44267503/devtools-failed-to-parse-sourcemap). – Jakub Aug 06 '20 at 11:24
  • i'm not really sure how to configure adding static path, can help me pls? – gpbaculio Aug 07 '20 at 02:44
  • Sure, you have 2 paths in your ingress, `path: /api/users/?(.*)` and `path: /?(.*)`, what I mean is that you could add another one with `path: /static`, so It would look like this `- path: /static backend: serviceName: client-srv servicePort: 3000`. – Jakub Aug 07 '20 at 07:33

0 Answers0