<p>I have implemented a web app using Nginx docker container on aws eks using ingress. Currently I'm creating the docker image with the docroot content and using Nginx to serve it. If in case my do root content is huge and I want to keep it outside the image how can I do it? Please share some examples.</p>
<p>Here's the docker file content</p>
<pre><code>FROM nginx
  
ADD . /usr/share/nginx/html/

COPY env.conf /etc/nginx/conf.d/

COPY nginx.conf /etc/nginx/

</code></pre>
<p>Content from env.conf</p>
<pre><code>server {
      listen 80 ;
      server_name localhost;
      root   /usr/share/nginx/html;
      index  index.html;
      large_client_header_buffers 4 32k;
      #default_type text/html;

     # CSS
      location / {
        add_header Cache-Control public;
       # Equivalent to above:
        expires     15m; # Indicate that the resource can be cached for 86400 seconds (24 hours)
        etag on; # Add an ETag header with an identifier that can be stored by the client

        rewrite ^/.*$ /index.html;
      }
     location ~ \/[^\/]*\.[^\/]*$ { }
     location /ABC {
        rewrite ^/abc(/|)$ /abc/index.html break;
        rewrite ^/abc/.*$ /abc/index.html break;
      }
   }

</code></pre>
<p>Here's the kubernetes yaml file.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-dev4
  namespace: abc
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: nginx-dev4
  replicas: 3 # tells deployment to run 1 pods matching the template
  template: # create pods using pod definition in this template
    metadata:
      labels:
        app: nginx-dev4
    spec:
      containers:
      - name: nginx-dev4
        image: XXXX.amazonaws.com/pcl-pv/dev4
        ports:
        - containerPort: 80
        volumeMounts:
          - mountPath: &quot;/usr/share/nginx/html&quot;
            name: &quot;task-pv-volume&quot;
      volumes:
        - name: task-pv-volume
          persistentVolumeClaim:
            claimName: task-pv-claim

---
apiVersion: v1
kind: Service
metadata:
  name: nginx-dev4
  namespace: pv
  labels:
    app: nginx-dev4
spec:
  ports:
  - name: http
    port: 9091
    targetPort: 80
  type: ClusterIP
  selector:
    app: nginx-dev4

---
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.kubernetes.io/ssl-passthrough: &quot;true&quot;
    ingress.kubernetes.io/ssl-redirect: &quot;true&quot;
  name: nginx-dev4
  namespace: pv
spec:
  rules:
    - host: XXXX.aws.com
      http:
        paths:
          - path: /
            backend:
              serviceName: nginx-dev4
              servicePort: 9091
</code></pre>
<p>added persistence volume, persistence volume claim to achieve this.</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  namespace: pv
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/home/ec2-user/nginx&quot;


---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: task-pv-claim
  namespace: pv
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 3Gi
</code></pre>

<p>you can mount the NFS or Cloud storage with the POD as option to server large content.</p>
<p>here is one nice example : <a href="https://medium.com/grensesnittet/mounting-a-gcp-bucket-as-nfs-in-kubernetes-8f6d3faf4da3" rel="nofollow noreferrer">https://medium.com/grensesnittet/mounting-a-gcp-bucket-as-nfs-in-kubernetes-8f6d3faf4da3</a></p>
<p>you can also use EFS, NFS, or Cloud storage bucket as per requirement.</p>
