Deploy production create-react-app via GitLab Auto DevOps to GKE

7/15/2018

I've been struggling to figure out why my create-react-app application won't display properly when using GitLab Auto DevOps and deploy to GKE. I'm thinking that it has something to do with how I'm serving the create-react-app and how the ingress-controller works, but I'm not totally sure.

For production, create-react-app suggests using yarn build and then package serve but I don't think that serve and ingress-controller play nice together. For reference here is my Dockerfile:

Dockerfile

FROM node:8.9.3-alpine

ARG NODE_ENV=production
ENV NODE_ENV=$NODE_ENV

# Set a working directory
WORKDIR /usr/src/app

COPY package.json yarn.lock ./
RUN set -ex; \
  if [ "$NODE_ENV" = "production" ]; then \
  yarn install --no-cache --frozen-lockfile --production; \
  npm install -g serve; \
  elif [ "$NODE_ENV" = "test" ]; then \
  touch yarn-error.log; \
  mkdir -m 777 build; \
  yarn install --no-cache --frozen-lockfile; \
  chown -R node:node build node_modules package.json yarn.lock yarn-error.log; \
  else \
  touch yarn-error.log; \
  mkdir -p -m 777 build node_modules /home/node/.cache/yarn; \
  chown -R node:node build node_modules package.json yarn.lock yarn-error.log /home/node/.cache/yarn; \
  fi;


COPY .env build* ./build/

USER node

CMD [ "serve", "-s", "build" ]

My application is really simple, it's just a single page with a few dummy routes.

When I push to master the whole pipeline succeeds, but the result is sort of a rendered view of my projects file structure. I've looked over the logs and the only thining that seems to be indicating any issue other that the state of the website is the ingress-controller logs which WARN me:

error obtaining PEM from secret app-6174385/production-auto-deploy-tls: error retrieving secret app-6174385/production-auto-deploy-tls: secret app-6174385/production-auto-deploy-tls was not found 

Has anyone had success deploying create-react-app to GKE via GitLab's Auto DevOps, if so I could really use some guidance. Also, happy to provide any additional information that would be helpful!

-- moku
create-react-app
gitlab
kubernetes
reactjs

1 Answer

7/16/2018

This error means that secret has not been created.

You can find information on how to set up Kubernetes cluster integration in Getting started with Auto DevOps instruction.

-- Akar
Source: StackOverflow