build: add Docker multi-stage build with nginx

This commit is contained in:
ahp
2026-08-25 21:09:05 +03:30
parent c34752d1b0
commit fa5da9c509
3 changed files with 95 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
location / {
try_files $uri $uri/ /index.html;
}
location /assets/ {
expires 1y;
add_header Cache-Control "public, no-transform";
access_log off;
}
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
add_header Access-Control-Allow-Origin "*";
expires 1M;
access_log off;
add_header Cache-Control "public";
}
server_tokens off;
error_log /var/log/nginx/error.log warn;
access_log /var/log/nginx/access.log;
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
+31
View File
@@ -0,0 +1,31 @@
FROM node:24-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm clean-install --verbose
COPY . .
RUN npm run build --verbose
FROM nginx:stable-alpine
RUN apk add --no-cache curl
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/dist /usr/share/nginx/html
COPY ./config/nginx/nginx.conf /etc/nginx/conf.d/default.conf
RUN chown -R nginx:nginx /usr/share/nginx/html && \
chmod -R 755 /usr/share/nginx/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost/ || exit 1
CMD ["nginx", "-g", "daemon off;"]
+15
View File
@@ -0,0 +1,15 @@
services:
kawaii-app:
build:
context: ..
dockerfile: docker/Dockerfile
container_name: kawaii-web
ports:
- "8181:80"
restart: unless-stopped
networks:
- kawaii-network
networks:
kawaii-network:
driver: bridge