Dockerfile updated to spa
All checks were successful
/ image_build (push) Successful in 1m53s

This commit is contained in:
tymur999
2026-03-17 14:59:03 -04:00
parent cbb6b997e2
commit 8976f4f9d8
9 changed files with 80 additions and 196 deletions

View File

@@ -1,12 +1,21 @@
FROM node:latest AS build FROM node:latest AS build
WORKDIR /blog WORKDIR /blog
COPY package.json /blog/ COPY package.json /blog/
RUN npm install RUN npm install
COPY . /blog/ COPY . /blog/
RUN npm run build RUN npm run build
FROM nginx:alpine FROM docker.io/nginx:trixie
COPY --from=build /blog/build/ /var/www/html/ RUN useradd tymur999 -u 3000
COPY nginx.conf /etc/nginx/ 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

56
k8s.yaml Normal file
View File

@@ -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

View File

@@ -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;
}
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -1,11 +0,0 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: blog-html
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1T
volumeName: blog-html

View File

@@ -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

View File

@@ -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

View File

@@ -1,5 +1,6 @@
worker_processes auto; worker_processes auto;
pid /tmp/nginx.pid; pid /tmp/nginx.pid;
user tymur999;
events { events {
worker_connections 1024; worker_connections 1024;
@@ -53,7 +54,7 @@ http {
# Serve static files # Serve static files
location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac)$ { 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 Cache-Control "public, max-age=15778463";
add_header Referrer-Policy "no-referrer" always; add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always; add_header X-Content-Type-Options "nosniff" always;
@@ -64,12 +65,18 @@ http {
} }
location ~ \.(otf|woff2?)$ { location ~ \.(otf|woff2?)$ {
try_files $uri /index.php$request_uri; try_files $uri @index;
expires 7d; # Cache-Control policy borrowed from `.htaccess` expires 7d; # Cache-Control policy borrowed from `.htaccess`
} }
location / { 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;
} }
} }
} }