Skip to content

Commit 961b268

Browse files
committed
doc build
1 parent 92bd294 commit 961b268

4 files changed

Lines changed: 344 additions & 0 deletions

File tree

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Build VitePress Docs and Push to Harbor
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
paths:
9+
- 'docs/**'
10+
- '.github/workflows/build-vitepress-docs.yml'
11+
release:
12+
types: [published]
13+
workflow_dispatch:
14+
inputs:
15+
image_tag:
16+
description: 'Docker image tag (default: latest)'
17+
required: false
18+
default: 'latest'
19+
20+
env:
21+
HARBOR_REGISTRY: ${{ vars.HARBOR_REGISTRY }}
22+
HARBOR_PROJECT: ${{ vars.HARBOR_PROJECT }}
23+
IMAGE_NAME: integration-subsystem-docs
24+
25+
jobs:
26+
build:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
image_tag: ${{ steps.meta.outputs.version }}
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: '20'
40+
cache: 'npm'
41+
cache-dependency-path: docs/package-lock.json
42+
43+
- name: Install dependencies
44+
working-directory: docs
45+
run: npm ci
46+
47+
- name: Build VitePress documentation
48+
working-directory: docs
49+
run: npm run docs:build
50+
51+
- name: Upload build artifact
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: vitepress-dist
55+
path: docs/.vitepress/dist
56+
retention-days: 7
57+
58+
docker:
59+
needs: build
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Checkout repository
63+
uses: actions/checkout@v4
64+
65+
- name: Download build artifact
66+
uses: actions/download-artifact@v4
67+
with:
68+
name: vitepress-dist
69+
path: docs/.vitepress/dist
70+
71+
- name: Set up Docker Buildx
72+
uses: docker/setup-buildx-action@v3
73+
74+
- name: Login to Harbor Registry
75+
uses: docker/login-action@v3
76+
with:
77+
registry: ${{ env.HARBOR_REGISTRY }}
78+
username: ${{ secrets.HARBOR_USERNAME }}
79+
password: ${{ secrets.HARBOR_PASSWORD }}
80+
81+
- name: Extract metadata for Docker
82+
id: meta
83+
uses: docker/metadata-action@v5
84+
with:
85+
images: ${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.IMAGE_NAME }}
86+
tags: |
87+
type=ref,event=branch
88+
type=ref,event=pr
89+
type=semver,pattern={{version}}
90+
type=semver,pattern={{major}}.{{minor}}
91+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
92+
type=raw,value=${{ github.event.inputs.image_tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
93+
type=sha,prefix=,format=short
94+
95+
- name: Build and push Docker image
96+
uses: docker/build-push-action@v5
97+
with:
98+
context: .
99+
file: ./docs/Dockerfile
100+
push: true
101+
tags: ${{ steps.meta.outputs.tags }}
102+
labels: ${{ steps.meta.outputs.labels }}
103+
cache-from: type=gha
104+
cache-to: type=gha,mode=max
105+
build-args: |
106+
BUILD_DATE=${{ github.event.repository.updated_at }}
107+
VCS_REF=${{ github.sha }}
108+
109+
- name: Generate SBOM
110+
uses: anchore/sbom-action@v0
111+
with:
112+
image: ${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
113+
format: spdx-json
114+
output-file: sbom.spdx.json
115+
116+
- name: Upload SBOM artifact
117+
uses: actions/upload-artifact@v4
118+
with:
119+
name: sbom
120+
path: sbom.spdx.json
121+
retention-days: 30
122+
123+
notify:
124+
needs: [build, docker]
125+
runs-on: ubuntu-latest
126+
if: always()
127+
steps:
128+
- name: Notify on success
129+
if: ${{ needs.docker.result == 'success' }}
130+
run: |
131+
echo "✅ Documentation successfully built and pushed to Harbor"
132+
echo "Image: ${{ env.HARBOR_REGISTRY }}/${{ env.HARBOR_PROJECT }}/${{ env.IMAGE_NAME }}"
133+
134+
- name: Notify on failure
135+
if: ${{ needs.docker.result == 'failure' }}
136+
run: |
137+
echo "❌ Failed to build or push documentation"
138+
exit 1

docs/.dockerignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build cache
5+
.vitepress/cache/
6+
7+
# IDE
8+
.idea/
9+
.vscode/
10+
*.swp
11+
*.swo
12+
13+
# OS
14+
.DS_Store
15+
Thumbs.db
16+
17+
# Logs
18+
*.log
19+
npm-debug.log*
20+
21+
# Test
22+
coverage/
23+
24+
# Temp
25+
*.tmp
26+
*.temp

docs/Dockerfile

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# =============================================================================
2+
# Dockerfile for VitePress Documentation
3+
# Integration Subsystem (Подсистема интеграции)
4+
# =============================================================================
5+
6+
# Build stage (if not using pre-built artifacts)
7+
FROM node:20-alpine AS builder
8+
9+
WORKDIR /app
10+
11+
# Copy package files
12+
COPY docs/package*.json ./
13+
14+
# Install dependencies
15+
RUN npm ci --only=production
16+
17+
# Copy documentation source
18+
COPY docs/ ./
19+
20+
# Build VitePress
21+
RUN npm run docs:build
22+
23+
# =============================================================================
24+
# Production stage - nginx for serving static files
25+
# =============================================================================
26+
FROM nginx:1.25-alpine AS production
27+
28+
LABEL maintainer="Integration Subsystem Team"
29+
LABEL org.opencontainers.image.title="Integration Subsystem Documentation"
30+
LABEL org.opencontainers.image.description="VitePress documentation for 1C:Enterprise Integration Subsystem"
31+
LABEL org.opencontainers.image.source="https://github.com/your-org/integration_subsystem"
32+
33+
# Build arguments for labels
34+
ARG BUILD_DATE
35+
ARG VCS_REF
36+
37+
LABEL org.opencontainers.image.created="${BUILD_DATE}"
38+
LABEL org.opencontainers.image.revision="${VCS_REF}"
39+
40+
# Install curl for healthcheck
41+
RUN apk add --no-cache curl
42+
43+
# Remove default nginx config
44+
RUN rm -rf /usr/share/nginx/html/*
45+
46+
# Copy custom nginx configuration
47+
COPY docs/nginx.conf /etc/nginx/nginx.conf
48+
49+
# Copy built documentation from builder stage
50+
# If using GitHub Actions artifact, this will be overwritten by the mounted dist folder
51+
COPY --from=builder /app/.vitepress/dist /usr/share/nginx/html
52+
53+
# Alternatively, if dist is pre-built and passed as context:
54+
# COPY docs/.vitepress/dist /usr/share/nginx/html
55+
56+
# Set proper permissions
57+
RUN chown -R nginx:nginx /usr/share/nginx/html && \
58+
chmod -R 755 /usr/share/nginx/html
59+
60+
# Expose port
61+
EXPOSE 80
62+
63+
# Healthcheck
64+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
65+
CMD curl -f http://localhost/ || exit 1
66+
67+
# Run nginx in foreground
68+
CMD ["nginx", "-g", "daemon off;"]

docs/nginx.conf

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# =============================================================================
2+
# Nginx configuration for VitePress documentation
3+
# Optimized for static site serving with SPA routing support
4+
# =============================================================================
5+
6+
user nginx;
7+
worker_processes auto;
8+
error_log /var/log/nginx/error.log warn;
9+
pid /var/run/nginx.pid;
10+
11+
events {
12+
worker_connections 1024;
13+
use epoll;
14+
multi_accept on;
15+
}
16+
17+
http {
18+
include /etc/nginx/mime.types;
19+
default_type application/octet-stream;
20+
21+
# Logging format
22+
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
23+
'$status $body_bytes_sent "$http_referer" '
24+
'"$http_user_agent" "$http_x_forwarded_for"';
25+
26+
access_log /var/log/nginx/access.log main;
27+
28+
# Performance optimizations
29+
sendfile on;
30+
tcp_nopush on;
31+
tcp_nodelay on;
32+
keepalive_timeout 65;
33+
types_hash_max_size 2048;
34+
35+
# Gzip compression
36+
gzip on;
37+
gzip_vary on;
38+
gzip_proxied any;
39+
gzip_comp_level 6;
40+
gzip_types
41+
text/plain
42+
text/css
43+
text/xml
44+
text/javascript
45+
application/json
46+
application/javascript
47+
application/xml
48+
application/xml+rss
49+
application/atom+xml
50+
image/svg+xml;
51+
52+
# Security headers
53+
add_header X-Frame-Options "SAMEORIGIN" always;
54+
add_header X-Content-Type-Options "nosniff" always;
55+
add_header X-XSS-Protection "1; mode=block" always;
56+
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
57+
58+
server {
59+
listen 80;
60+
listen [::]:80;
61+
server_name _;
62+
63+
root /usr/share/nginx/html;
64+
index index.html;
65+
66+
# Charset
67+
charset utf-8;
68+
69+
# VitePress clean URLs support
70+
location / {
71+
try_files $uri $uri/ $uri.html /index.html;
72+
}
73+
74+
# Cache static assets
75+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
76+
expires 1y;
77+
add_header Cache-Control "public, immutable";
78+
access_log off;
79+
}
80+
81+
# Cache HTML with shorter TTL for updates
82+
location ~* \.html$ {
83+
expires 1h;
84+
add_header Cache-Control "public, must-revalidate";
85+
}
86+
87+
# Health check endpoint
88+
location /health {
89+
access_log off;
90+
return 200 "healthy\n";
91+
add_header Content-Type text/plain;
92+
}
93+
94+
# Disable access to hidden files
95+
location ~ /\. {
96+
deny all;
97+
access_log off;
98+
log_not_found off;
99+
}
100+
101+
# Error pages
102+
error_page 404 /404.html;
103+
location = /404.html {
104+
internal;
105+
}
106+
107+
error_page 500 502 503 504 /50x.html;
108+
location = /50x.html {
109+
internal;
110+
}
111+
}
112+
}

0 commit comments

Comments
 (0)