fix: CI调整
This commit is contained in:
1 parent
311bd719c9
commit
c88da44db0
8 files changed
+85
-51
No files matched your search
@@ -47,6 +47,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ./Dockerfile.frontend
|
file: ./Dockerfile.frontend
|
||||||
|
build-args: |
|
||||||
|
NGINX_CONF=nginx-ci.conf
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
|||||||
-24
@@ -1,24 +0,0 @@
|
|||||||
# Multi-stage build
|
|
||||||
FROM node:18-alpine AS frontend-builder
|
|
||||||
WORKDIR /app/frontend
|
|
||||||
COPY frontend/package*.json ./
|
|
||||||
RUN npm install
|
|
||||||
COPY frontend/ ./
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
FROM golang:1.23-alpine AS backend-builder
|
|
||||||
WORKDIR /app/backend
|
|
||||||
COPY backend/go.mod backend/go.sum ./
|
|
||||||
RUN go mod download
|
|
||||||
COPY backend/ ./
|
|
||||||
RUN go build -o license-manager cmd/main.go
|
|
||||||
|
|
||||||
FROM alpine:latest
|
|
||||||
RUN apk --no-cache add ca-certificates
|
|
||||||
WORKDIR /app
|
|
||||||
COPY --from=backend-builder /app/backend/license-manager .
|
|
||||||
COPY --from=frontend-builder /app/frontend/dist ./static
|
|
||||||
COPY backend/configs/config.example.yaml ./config.yaml
|
|
||||||
COPY backend/configs/i18n/ ./configs/i18n/
|
|
||||||
EXPOSE 18888
|
|
||||||
CMD ["./license-manager"]
|
|
||||||
+4
-4
@@ -22,10 +22,10 @@ FROM nginx:alpine
|
|||||||
# Copy built assets
|
# Copy built assets
|
||||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
# Copy nginx configuration template and entrypoint to render from env
|
# Selectable nginx configuration (default: nginx.conf). Use build-arg to switch.
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf.template
|
ARG NGINX_CONF=nginx.conf
|
||||||
COPY frontend/entrypoint/10-envsubst.sh /docker-entrypoint.d/10-envsubst.sh
|
ENV NGINX_CONF=${NGINX_CONF}
|
||||||
RUN chmod +x /docker-entrypoint.d/10-envsubst.sh
|
COPY ${NGINX_CONF} /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
# Create log directory
|
# Create log directory
|
||||||
RUN mkdir -p /var/log/nginx
|
RUN mkdir -p /var/log/nginx
|
||||||
|
|||||||
@@ -87,8 +87,6 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
# Set API upstream for automated deployments (e.g., external gateway or backend host)
|
|
||||||
- API_UPSTREAM=${API_UPSTREAM:-http://backend:18888}
|
|
||||||
ports:
|
ports:
|
||||||
- "${FRONTEND_PORT:-80}:80"
|
- "${FRONTEND_PORT:-80}:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- TZ=Asia/Shanghai
|
- TZ=Asia/Shanghai
|
||||||
- API_UPSTREAM=http://backend:18888
|
|
||||||
ports:
|
ports:
|
||||||
- "18080:80"
|
- "18080:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
# Default upstream if not provided (docker compose dev network)
|
|
||||||
: "${API_UPSTREAM:=http://backend:18888}"
|
|
||||||
|
|
||||||
TEMPLATE="/etc/nginx/conf.d/default.conf.template"
|
|
||||||
TARGET="/etc/nginx/conf.d/default.conf"
|
|
||||||
|
|
||||||
if [ -f "$TEMPLATE" ]; then
|
|
||||||
echo "[entrypoint] Rendering nginx config with API_UPSTREAM=$API_UPSTREAM"
|
|
||||||
envsubst '\$API_UPSTREAM' < "$TEMPLATE" > "$TARGET"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name _;
|
||||||
|
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
# Gzip compression
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_types
|
||||||
|
text/plain
|
||||||
|
text/css
|
||||||
|
text/xml
|
||||||
|
text/javascript
|
||||||
|
application/javascript
|
||||||
|
application/xml+rss
|
||||||
|
application/json
|
||||||
|
image/svg+xml;
|
||||||
|
|
||||||
|
# Security headers
|
||||||
|
add_header X-Frame-Options DENY;
|
||||||
|
add_header X-Content-Type-Options nosniff;
|
||||||
|
add_header X-XSS-Protection "1; mode=block";
|
||||||
|
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
||||||
|
|
||||||
|
# Handle Vue Router history mode
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Cache static assets
|
||||||
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||||
|
expires 1y;
|
||||||
|
add_header Cache-Control "public, immutable";
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# API proxy to backend on localhost (for CI/standalone frontend deployments)
|
||||||
|
location /api/ {
|
||||||
|
proxy_pass http://127.0.0.1:18888;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_connect_timeout 60s;
|
||||||
|
proxy_send_timeout 60s;
|
||||||
|
proxy_read_timeout 60s;
|
||||||
|
|
||||||
|
# CORS headers passthrough
|
||||||
|
proxy_pass_header Access-Control-Allow-Origin;
|
||||||
|
proxy_pass_header Access-Control-Allow-Methods;
|
||||||
|
proxy_pass_header Access-Control-Allow-Headers;
|
||||||
|
proxy_pass_header Access-Control-Allow-Credentials;
|
||||||
|
|
||||||
|
# Logs for debugging
|
||||||
|
access_log /var/log/nginx/api_proxy.log;
|
||||||
|
error_log /var/log/nginx/api_proxy_error.log;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Disable access to hidden files
|
||||||
|
location ~ /\. {
|
||||||
|
deny all;
|
||||||
|
access_log off;
|
||||||
|
log_not_found off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Custom error pages
|
||||||
|
error_page 404 /index.html;
|
||||||
|
error_page 500 502 503 504 /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
+3
-2
@@ -39,9 +39,10 @@ server {
|
|||||||
access_log off;
|
access_log off;
|
||||||
}
|
}
|
||||||
|
|
||||||
# API proxy to backend (configurable via $API_UPSTREAM)
|
# API proxy to backend (container network)
|
||||||
location /api/ {
|
location /api/ {
|
||||||
proxy_pass $API_UPSTREAM;
|
# Keep original request path; backend service name resolves inside Docker network
|
||||||
|
proxy_pass http://backend:18888;
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
|||||||
Reference in new issue
Block a user