This is my dockerfile used to building an image for kubernetes/openshift deployment:
FROM node:8.11.4
RUN mkdir /app
WORKDIR /app
COPY package.json .
RUN npm install
COPY src src
COPY public public
EXPOSE 3000
CMD ["npm", "start"]
The source code this app is cloned from: https://github.com/nodeshift-starters/react-web-app
This is my deployment yaml:
apiVersion: v1
kind: DeploymentConfig
metadata:
name: 'react-app'
labels:
app: 'react-app'
spec:
template:
spec:
initContainers:
- name: init-react
imagePullPolicy: IfNotPresent
image: "docker-registry.default.svc:5000/${NAMESPACE}/react-app"
command: ["sh", "-c"]
args: ["cp -n -r /app/* /tmp/app; sleep 1; ls -al"]
volumeMounts:
- mountPath: /tmp/app
name: react-storage-volume
containers:
- image: 'react-app:latest'
name: 'react-app'
securityContext:
privileged: false
ports:
- containerPort: 3000
name: http
protocol: TCP
resources:
limits:
memory: 500Mi
volumeMounts:
- name: react-storage-volume
mountPath: /app
volumes:
- name: react-storage-volume
persistentVolumeClaim:
claimName: "${pv_react}-claim"
metadata:
labels:
app: 'react-app'
replicas: 1
selector:
app: 'react-app'
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- 'react-app'
from:
kind: ImageStreamTag
name: 'react-app:latest'
The /app is mounted to nfs mount path : /mnt/k8sMount/react-data/.
The observation is whenever a change is done to src/App.js in the NFS mount path, it is getting updated to the pod(i have exec to the pod and checked its content) but when the web UI is refreshed in the browser the changes are not shown up.
Another observation is if changes to src/App.js inside the pod then upon web UI refresh in browser the changes appear.
Since I would want changes done to src/App.js in the NFS mount path to reflect in the web UI, please suggest to me if anything is wrong the deployment or if any alternative to achieve this. Thanks in Advance.