Skip to content

Commit 6a96e75

Browse files
authored
Merge pull request #1 from oldjs/docker
2 parents 73f18b9 + 5a53cdc commit 6a96e75

11 files changed

Lines changed: 1216 additions & 116 deletions

.github/workflows/docker-build.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [main, master, develop, docker]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: [main, master, develop, docker]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
28+
- name: Log in to Container Registry
29+
if: github.event_name != 'pull_request'
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Extract metadata
37+
id: meta
38+
uses: docker/metadata-action@v5
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
tags: |
42+
type=ref,event=branch
43+
type=ref,event=pr
44+
type=semver,pattern={{version}}
45+
type=semver,pattern={{major}}.{{minor}}
46+
type=semver,pattern={{major}}
47+
type=raw,value=latest,enable={{is_default_branch}}
48+
49+
- name: Build and push Docker image
50+
uses: docker/build-push-action@v5
51+
with:
52+
context: .
53+
platforms: linux/amd64,linux/arm64
54+
push: ${{ github.event_name != 'pull_request' }}
55+
tags: ${{ steps.meta.outputs.tags }}
56+
labels: ${{ steps.meta.outputs.labels }}
57+
cache-from: type=gha
58+
cache-to: type=gha,mode=max
59+
60+
- name: Run Trivy vulnerability scanner
61+
if: github.event_name != 'pull_request' && steps.meta.outputs.tags != ''
62+
uses: aquasecurity/trivy-action@master
63+
with:
64+
image-ref: ${{ env.REGISTRY }}/${{ github.repository }}
65+
format: "sarif"
66+
output: "trivy-results.sarif"
67+
continue-on-error: true
68+
69+
- name: Upload Trivy scan results to GitHub Security tab
70+
if: github.event_name != 'pull_request' && steps.meta.outputs.tags != ''
71+
uses: github/codeql-action/upload-sarif@v2
72+
with:
73+
sarif_file: "trivy-results.sarif"
74+
continue-on-error: true
75+
76+
deploy:
77+
needs: build
78+
runs-on: ubuntu-latest
79+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
80+
# environment: production # 如果需要使用GitHub环境,请先在仓库设置中创建
81+
82+
steps:
83+
- name: Deploy to production
84+
run: |
85+
echo "部署到生产环境的步骤"
86+
echo "可以在这里添加部署脚本或调用部署API"
87+
echo "例如:kubectl apply -f k8s/ 或者调用云服务商的部署API"

.gitignore

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.env.local
107+
.env.*.local
108+
.venv
109+
env/
110+
venv/
111+
ENV/
112+
env.bak/
113+
venv.bak/
114+
115+
# Spyder project settings
116+
.spyderproject
117+
.spyproject
118+
119+
# Rope project settings
120+
.ropeproject
121+
122+
# mkdocs documentation
123+
/site
124+
125+
# mypy
126+
.mypy_cache/
127+
.dmypy.json
128+
dmypy.json
129+
130+
# Pyre type checker
131+
.pyre/
132+
133+
# IDE
134+
.vscode/
135+
.idea/
136+
*.swp
137+
*.swo
138+
*~
139+
140+
# OS generated files
141+
.DS_Store
142+
.DS_Store?
143+
._*
144+
.Spotlight-V100
145+
.Trashes
146+
ehthumbs.db
147+
Thumbs.db
148+
149+
# Logs
150+
logs/
151+
*.log
152+
153+
# Runtime data
154+
pids
155+
*.pid
156+
*.seed
157+
*.pid.lock
158+
159+
# Coverage directory used by tools like istanbul
160+
coverage/
161+
162+
# nyc test coverage
163+
.nyc_output
164+
165+
# Dependency directories
166+
node_modules/
167+
168+
# Optional npm cache directory
169+
.npm
170+
171+
# Optional REPL history
172+
.node_repl_history
173+
174+
# Output of 'npm pack'
175+
*.tgz
176+
177+
# Yarn Integrity file
178+
.yarn-integrity
179+
180+
# dotenv environment variables file
181+
.env.test
182+
183+
# parcel-bundler cache (https://parceljs.org/)
184+
.cache
185+
.parcel-cache
186+
187+
# next.js build output
188+
.next
189+
190+
# nuxt.js build output
191+
.nuxt
192+
193+
# vuepress build output
194+
.vuepress/dist
195+
196+
# Serverless directories
197+
.serverless/
198+
199+
# FuseBox cache
200+
.fusebox/
201+
202+
# DynamoDB Local files
203+
.dynamodb/
204+
205+
# TernJS port file
206+
.tern-port
207+
208+
# Docker
209+
.dockerignore
210+
211+
# Temporary files
212+
*.tmp
213+
*.temp
214+
.cache/
215+
216+
# Application specific
217+
config/local.py
218+
uploads/
219+
downloads/

0 commit comments

Comments
 (0)