From 8976f4f9d84738dd76dc2ef8b027d7e51b8aba1d Mon Sep 17 00:00:00 2001 From: tymur999 Date: Tue, 17 Mar 2026 14:59:03 -0400 Subject: [PATCH] Dockerfile updated to spa --- Dockerfile | 19 ++++++++--- k8s.yaml | 56 ++++++++++++++++++++++++++++++ kube/configmap.yaml | 81 -------------------------------------------- kube/deployment.yaml | 40 ---------------------- kube/ingress.yaml | 22 ------------ kube/pvc.yaml | 11 ------ kube/service.yaml | 13 ------- kube/volume.yaml | 21 ------------ nginx.conf | 13 +++++-- 9 files changed, 80 insertions(+), 196 deletions(-) create mode 100644 k8s.yaml delete mode 100644 kube/configmap.yaml delete mode 100644 kube/deployment.yaml delete mode 100644 kube/ingress.yaml delete mode 100644 kube/pvc.yaml delete mode 100644 kube/service.yaml delete mode 100644 kube/volume.yaml diff --git a/Dockerfile b/Dockerfile index 62cbecd..25ff3f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,21 @@ FROM node:latest AS build - WORKDIR /blog COPY package.json /blog/ RUN npm install - COPY . /blog/ RUN npm run build -FROM nginx:alpine -COPY --from=build /blog/build/ /var/www/html/ -COPY nginx.conf /etc/nginx/ \ No newline at end of file +FROM docker.io/nginx:trixie +RUN useradd tymur999 -u 3000 +RUN chown tymur999:tymur999 -R /etc/logrotate.d/nginx \ + /etc/nginx \ + /etc/init.d/nginx \ + /usr/lib/nginx \ + /usr/share/nginx \ + /var/cache/nginx \ + /var/log/nginx +USER tymur999:tymur999 + +COPY --from=build --chown=tymur999:tymur999 /blog/build/ /var/www/html/ +COPY --link nginx.conf /etc/nginx/ +EXPOSE 8000 \ No newline at end of file diff --git a/k8s.yaml b/k8s.yaml new file mode 100644 index 0000000..43a115e --- /dev/null +++ b/k8s.yaml @@ -0,0 +1,56 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: &metadata + name: blog + labels: &label + app: blog +spec: + selector: + matchLabels: *label + template: + metadata: *metadata + spec: + containers: + - name: nginx + image: gitea.tymur999.com/tymur999/blog:latest + ports: + - containerPort: 8000 + name: http +--- +apiVersion: v1 +kind: Service +metadata: + name: blog + labels: &labels + app: blog +spec: + selector: *labels + ports: + - port: 8000 + protocol: TCP + targetPort: http + name: http +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: blog + labels: + app: blog +spec: + ingressClassName: traefik + tls: + - hosts: + - tymur999.com + rules: + - host: tymur999.com + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: blog + port: + name: http \ No newline at end of file diff --git a/kube/configmap.yaml b/kube/configmap.yaml deleted file mode 100644 index 58fe256..0000000 --- a/kube/configmap.yaml +++ /dev/null @@ -1,81 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: blog-nginx -data: - nginx.conf: | - worker_processes auto; - pid /tmp/nginx.pid; - - events { - worker_connections 1024; - } - - http { - include mime.types; - - sendfile on; - tcp_nopush on; - # Prevent nginx HTTP Server Detection - server_tokens off; - - keepalive_timeout 65; - - server { - server_name tymur999.com; - listen 8000; - - # set max upload size and increase upload timeout: - client_max_body_size 10G; - client_body_timeout 300s; - - proxy_set_header Host $http_host; - proxy_set_header X-Forwarded-Proto https; - - gzip on; - gzip_vary on; - gzip_comp_level 4; - gzip_min_length 256; - gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; - gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; - - # HTTP response headers borrowed from Nextcloud `.htaccess` - add_header Referrer-Policy "no-referrer" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Permitted-Cross-Domain-Policies "none" always; - add_header X-Robots-Tag "noindex, nofollow" always; - add_header X-XSS-Protection "1; mode=block" always; - - # Path to the root of your installation - root /var/www/html; - index index.html; - - location = /robots.txt { - allow all; - log_not_found off; - access_log off; - } - - # Serve static files - location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac)$ { - try_files $uri /index.php$request_uri; - add_header Cache-Control "public, max-age=15778463"; - add_header Referrer-Policy "no-referrer" always; - add_header X-Content-Type-Options "nosniff" always; - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Permitted-Cross-Domain-Policies "none" always; - add_header X-Robots-Tag "noindex, nofollow" always; - add_header X-XSS-Protection "1; mode=block" always; - } - - location ~ \.(otf|woff2?)$ { - try_files $uri /index.php$request_uri; - expires 7d; # Cache-Control policy borrowed from `.htaccess` - } - - location / { - try_files $uri $uri/ /index.php$request_uri; - } - } - } diff --git a/kube/deployment.yaml b/kube/deployment.yaml deleted file mode 100644 index 5b84155..0000000 --- a/kube/deployment.yaml +++ /dev/null @@ -1,40 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: &meta - name: blog - labels: &labels - app: blog -spec: - replicas: 1 - selector: - matchLabels: *labels - template: - metadata: *meta - spec: - restartPolicy: Always - containers: - - name: nginx - image: nginx - imagePullPolicy: IfNotPresent - ports: - - containerPort: 8000 - protocol: TCP - name: http - volumeMounts: - - mountPath: /var/www/html - name: html - readOnly: true - - mountPath: /etc/nginx/nginx.conf - name: nginx-conf - subPath: nginx.conf - readOnly: true - volumes: - - name: html - persistentVolumeClaim: - claimName: blog-html - - name: nginx-conf - configMap: - name: blog-nginx - items: - - key: nginx.conf - path: nginx.conf \ No newline at end of file diff --git a/kube/ingress.yaml b/kube/ingress.yaml deleted file mode 100644 index 472241a..0000000 --- a/kube/ingress.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: blog - labels: - app: blog -spec: - ingressClassName: traefik - tls: - - hosts: - - tymur999.com - rules: - - host: tymur999.com - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: blog - port: - name: http \ No newline at end of file diff --git a/kube/pvc.yaml b/kube/pvc.yaml deleted file mode 100644 index a0826f2..0000000 --- a/kube/pvc.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: blog-html -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 1T - volumeName: blog-html diff --git a/kube/service.yaml b/kube/service.yaml deleted file mode 100644 index 706b178..0000000 --- a/kube/service.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: blog - labels: &labels - app: blog -spec: - ports: - - port: 80 - protocol: TCP - targetPort: http - name: http - selector: *labels \ No newline at end of file diff --git a/kube/volume.yaml b/kube/volume.yaml deleted file mode 100644 index ead1a49..0000000 --- a/kube/volume.yaml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: blog-html -spec: - capacity: - storage: 1T - volumeMode: Filesystem - accessModes: - - ReadWriteOnce - persistentVolumeReclaimPolicy: Delete - local: - path: /hdd/blog - nodeAffinity: - required: - nodeSelectorTerms: - - matchExpressions: - - key: kubernetes.io/hostname - operator: In - values: - - tymur999srv \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index d2bd50f..5ffbec7 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,5 +1,6 @@ worker_processes auto; pid /tmp/nginx.pid; +user tymur999; events { worker_connections 1024; @@ -53,7 +54,7 @@ http { # Serve static files location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac)$ { - try_files $uri /index.php$request_uri; + try_files $uri @index; add_header Cache-Control "public, max-age=15778463"; add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; @@ -64,12 +65,18 @@ http { } location ~ \.(otf|woff2?)$ { - try_files $uri /index.php$request_uri; + try_files $uri @index; expires 7d; # Cache-Control policy borrowed from `.htaccess` } location / { - try_files $uri $uri/ /index.php$request_uri; + try_files $uri @index; + } + + location @index { + add_header Cache-Control no-cache; + expires 0; + try_files /index.html =404; } } } \ No newline at end of file