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:
|
||||
context: .
|
||||
file: ./Dockerfile.frontend
|
||||
build-args: |
|
||||
NGINX_CONF=nginx-ci.conf
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
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 --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
# Copy nginx configuration template and entrypoint to render from env
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf.template
|
||||
COPY frontend/entrypoint/10-envsubst.sh /docker-entrypoint.d/10-envsubst.sh
|
||||
RUN chmod +x /docker-entrypoint.d/10-envsubst.sh
|
||||
# Selectable nginx configuration (default: nginx.conf). Use build-arg to switch.
|
||||
ARG NGINX_CONF=nginx.conf
|
||||
ENV NGINX_CONF=${NGINX_CONF}
|
||||
COPY ${NGINX_CONF} /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Create log directory
|
||||
RUN mkdir -p /var/log/nginx
|
||||
|
||||
@@ -87,8 +87,6 @@ services:
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
# Set API upstream for automated deployments (e.g., external gateway or backend host)
|
||||
- API_UPSTREAM=${API_UPSTREAM:-http://backend:18888}
|
||||
ports:
|
||||
- "${FRONTEND_PORT:-80}:80"
|
||||
depends_on:
|
||||
|
||||
@@ -68,7 +68,6 @@ services:
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- API_UPSTREAM=http://backend:18888
|
||||
ports:
|
||||
- "18080:80"
|
||||
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;
|
||||
}
|
||||
|
||||
# API proxy to backend (configurable via $API_UPSTREAM)
|
||||
# API proxy to backend (container network)
|
||||
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 X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in new issue
Block a user