mirror of
https://github.com/StepanovPlaton/AboutMe.git
synced 2026-04-03 20:30:49 +04:00
Update docker deploy
This commit is contained in:
19
Dockerfile
19
Dockerfile
@@ -4,14 +4,6 @@ FROM node:22-alpine AS builder
|
|||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Accept build arguments
|
|
||||||
ARG OAUTH_GITHUB_CLIENT_ID
|
|
||||||
ARG OAUTH_GITHUB_CLIENT_SECRET
|
|
||||||
|
|
||||||
# Set environment variables from build args
|
|
||||||
ENV OAUTH_GITHUB_CLIENT_ID=${OAUTH_GITHUB_CLIENT_ID}
|
|
||||||
ENV OAUTH_GITHUB_CLIENT_SECRET=${OAUTH_GITHUB_CLIENT_SECRET}
|
|
||||||
|
|
||||||
# Copy package files
|
# Copy package files
|
||||||
COPY package.json package-lock.json* ./
|
COPY package.json package-lock.json* ./
|
||||||
|
|
||||||
@@ -21,19 +13,28 @@ RUN npm ci
|
|||||||
# Copy source code
|
# Copy source code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
# Accept build arguments and set environment variables
|
||||||
|
ARG OAUTH_GITHUB_CLIENT_ID
|
||||||
|
ARG OAUTH_GITHUB_CLIENT_SECRET
|
||||||
|
ENV OAUTH_GITHUB_CLIENT_ID=${OAUTH_GITHUB_CLIENT_ID}
|
||||||
|
ENV OAUTH_GITHUB_CLIENT_SECRET=${OAUTH_GITHUB_CLIENT_SECRET}
|
||||||
|
|
||||||
# Build the application
|
# Build the application
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 2: Production
|
# Stage 2: Production
|
||||||
FROM nginx:alpine AS production
|
FROM nginx:alpine AS production
|
||||||
|
|
||||||
|
# Remove default nginx config
|
||||||
|
RUN rm -f /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
# Copy built files from builder stage
|
# Copy built files from builder stage
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
# Copy nginx configuration
|
# Copy nginx configuration
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
# Expose port 8091 (for rootless podman)
|
# Expose port 8091
|
||||||
EXPOSE 8091
|
EXPOSE 8091
|
||||||
|
|
||||||
# Start nginx
|
# Start nginx
|
||||||
|
|||||||
49
nginx.conf
49
nginx.conf
@@ -1,59 +1,24 @@
|
|||||||
server {
|
server {
|
||||||
listen 8091;
|
listen 8091;
|
||||||
server_name localhost;
|
server_name _;
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html;
|
index index.html;
|
||||||
|
|
||||||
# Gzip compression
|
# Gzip compression
|
||||||
gzip on;
|
gzip on;
|
||||||
gzip_vary on;
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
gzip_min_length 1024;
|
|
||||||
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript;
|
|
||||||
|
|
||||||
# Security headers
|
# Cache static assets
|
||||||
add_header X-Content-Type-Options "nosniff" always;
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
add_header X-Frame-Options "DENY" always;
|
expires 1y;
|
||||||
add_header X-XSS-Protection "1; mode=block" always;
|
add_header Cache-Control "public, immutable";
|
||||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
||||||
|
|
||||||
# Cache control for static assets
|
|
||||||
location ~* ^/_astro/ {
|
|
||||||
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
|
||||||
try_files $uri =404;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~* ^/assets/ {
|
# Main location
|
||||||
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
|
||||||
try_files $uri =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~* ^/favicon/ {
|
|
||||||
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
|
||||||
try_files $uri =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~* ^/pio/ {
|
|
||||||
add_header Cache-Control "public, max-age=31536000, immutable" always;
|
|
||||||
try_files $uri =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
# CORS headers for RSS/Atom feeds
|
|
||||||
location ~* ^/(atom|rss)\.xml$ {
|
|
||||||
add_header Access-Control-Allow-Origin "*" always;
|
|
||||||
add_header Access-Control-Allow-Methods "GET" always;
|
|
||||||
add_header Access-Control-Max-Age "86400" always;
|
|
||||||
try_files $uri =404;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Main location - SPA fallback
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ $uri.html /index.html;
|
try_files $uri $uri/ $uri.html /index.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Error pages
|
# Error pages
|
||||||
error_page 404 /404.html;
|
error_page 404 /404.html;
|
||||||
error_page 500 502 503 504 /50x.html;
|
|
||||||
location = /50x.html {
|
|
||||||
root /usr/share/nginx/html;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.4 KiB |
Reference in New Issue
Block a user