Skip to content

Commit 14725e8

Browse files
committed
v2.0.1
Signed-off-by: TIANHE <TIANHE@GMAIL.COM>
1 parent 0022bc7 commit 14725e8

52 files changed

Lines changed: 8154 additions & 2025 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Dependencies and build output
2+
node_modules/
3+
dist/
4+
build/
5+
6+
# Native app projects and signing material are not needed for the web image.
7+
android/
8+
ios/
9+
signing/
10+
resources/
11+
.capacitor/
12+
.capacitor.local.json
13+
14+
# Local caches and generated files
15+
.cache/
16+
auto-imports.d.ts
17+
*.log
18+
npm-debug.log*
19+
yarn-debug.log*
20+
pnpm-debug.log*
21+
22+
# Local env files
23+
.env
24+
.env.local
25+
.env.*.local
26+
27+
# Git and CI files
28+
.git/
29+
.gitignore
30+
.gitattributes
31+
.github/
32+
33+
# Editor / OS junk
34+
.idea/
35+
.vscode/
36+
*.swp
37+
*.swo
38+
*~
39+
.DS_Store
40+
Thumbs.db
41+
42+
# Test output
43+
coverage/
44+
.nyc_output/
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Publish mobile image to GHCR
2+
3+
# Build the QuantDinger mobile H5/PWA bundle and publish a multi-arch nginx
4+
# image to GitHub Container Registry. Version tags also create a GitHub Release
5+
# with a dist.tar.gz static bundle attached.
6+
#
7+
# Consumed as:
8+
# ghcr.io/<owner>/quantdinger-mobile:<tag>
9+
#
10+
# Triggers:
11+
# - push of a version tag matching `v*` (e.g. v4.0.1) -> semver + latest
12+
# tags pushed AND a GitHub Release published
13+
# - manual workflow_dispatch -> short-SHA tag only, no Release
14+
#
15+
# First-time setup: after the first successful run, visit
16+
# https://github.com/users/<owner>/packages/container/quantdinger-mobile/settings
17+
# and set the package visibility to public if anonymous `docker pull` is desired.
18+
19+
on:
20+
push:
21+
tags:
22+
- 'v*'
23+
workflow_dispatch:
24+
25+
concurrency:
26+
group: release-mobile-${{ github.ref }}
27+
cancel-in-progress: true
28+
29+
permissions:
30+
contents: write
31+
packages: write
32+
33+
jobs:
34+
publish:
35+
name: Build & push mobile image
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v3
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Log in to GHCR
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Extract image metadata
55+
id: meta
56+
uses: docker/metadata-action@v5
57+
with:
58+
images: ghcr.io/${{ github.repository_owner }}/quantdinger-mobile
59+
tags: |
60+
type=ref,event=tag
61+
type=semver,pattern={{version}}
62+
type=semver,pattern={{major}}.{{minor}}
63+
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
64+
type=sha,format=short
65+
66+
- name: Build and push mobile web image
67+
uses: docker/build-push-action@v6
68+
with:
69+
context: .
70+
file: ./Dockerfile
71+
platforms: linux/amd64,linux/arm64
72+
push: true
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}
75+
cache-from: type=gha,scope=mobile
76+
cache-to: type=gha,mode=max,scope=mobile
77+
build-args: |
78+
APP_VERSION=${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || '' }}
79+
GIT_TAG=${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || '' }}
80+
provenance: false
81+
82+
- name: Extract dist tarball from just-pushed image
83+
if: startsWith(github.ref, 'refs/tags/v')
84+
env:
85+
IMAGE: ghcr.io/${{ github.repository_owner }}/quantdinger-mobile:${{ github.ref_name }}
86+
run: |
87+
set -euo pipefail
88+
docker pull --platform linux/amd64 "$IMAGE"
89+
CID=$(docker create --platform linux/amd64 "$IMAGE")
90+
mkdir -p _dist
91+
docker cp "$CID:/usr/share/nginx/html/." _dist/
92+
docker rm "$CID" > /dev/null
93+
tar -czf dist.tar.gz -C _dist .
94+
sha256sum dist.tar.gz | tee dist.tar.gz.sha256
95+
du -h dist.tar.gz
96+
97+
- name: Create or update GitHub Release
98+
if: startsWith(github.ref, 'refs/tags/v')
99+
uses: softprops/action-gh-release@v2
100+
with:
101+
generate_release_notes: true
102+
append_body: true
103+
files: |
104+
dist.tar.gz
105+
dist.tar.gz.sha256
106+
body: |
107+
## QuantDinger Mobile ${{ github.ref_name }}
108+
109+
**Docker image (multi-arch, amd64 + arm64):**
110+
111+
```bash
112+
docker pull ghcr.io/${{ github.repository_owner }}/quantdinger-mobile:${{ github.ref_name }}
113+
```
114+
115+
Example:
116+
117+
```bash
118+
docker run -d --name quantdinger-mobile -p 8081:80 ghcr.io/${{ github.repository_owner }}/quantdinger-mobile:${{ github.ref_name }}
119+
```
120+
121+
**Static bundle:** `dist.tar.gz` can be extracted into any nginx/static host as `/usr/share/nginx/html/` (verify with `dist.tar.gz.sha256`).
122+
123+
---

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# QuantDinger Mobile web image published to GHCR.
2+
#
3+
# The Vite build runs once on the native builder platform. The generated
4+
# static assets are architecture-neutral, so the nginx stage can publish a
5+
# cheap multi-arch image for linux/amd64 and linux/arm64.
6+
7+
ARG NODE_IMAGE=node:22-alpine
8+
ARG NGINX_IMAGE=nginx:1.27-alpine
9+
10+
FROM --platform=$BUILDPLATFORM ${NODE_IMAGE} AS builder
11+
ARG APP_VERSION=""
12+
ARG GIT_TAG=""
13+
WORKDIR /app
14+
15+
COPY package*.json ./
16+
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
17+
18+
COPY . .
19+
RUN APP_VERSION="$APP_VERSION" GIT_TAG="$GIT_TAG" npm run build
20+
21+
FROM ${NGINX_IMAGE}
22+
23+
RUN apk add --no-cache curl
24+
25+
COPY deploy/nginx-mobile.conf /etc/nginx/conf.d/default.conf
26+
COPY --from=builder /app/dist /usr/share/nginx/html
27+
28+
EXPOSE 80
29+
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
30+
CMD curl -fsS http://127.0.0.1/ >/dev/null || exit 1
31+
32+
CMD ["nginx", "-g", "daemon off;"]

deploy/nginx-mobile.conf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
server {
2+
listen 80;
3+
server_name _;
4+
5+
root /usr/share/nginx/html;
6+
index index.html;
7+
8+
gzip on;
9+
gzip_comp_level 5;
10+
gzip_min_length 1024;
11+
gzip_types
12+
text/plain
13+
text/css
14+
text/javascript
15+
application/javascript
16+
application/json
17+
application/manifest+json
18+
image/svg+xml;
19+
20+
location /assets/ {
21+
try_files $uri =404;
22+
access_log off;
23+
expires 30d;
24+
add_header Cache-Control "public, immutable";
25+
}
26+
27+
location = /manifest.webmanifest {
28+
try_files $uri =404;
29+
add_header Cache-Control "public, max-age=300";
30+
}
31+
32+
location / {
33+
try_files $uri $uri/ /index.html;
34+
add_header Cache-Control "no-cache";
35+
}
36+
}

index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
99
<meta name="format-detection" content="telephone=no" />
1010

11-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
12-
<link rel="apple-touch-icon" href="/icon-192.png" />
11+
<link rel="icon" href="/favicon.ico" sizes="any" />
12+
<link rel="icon" type="image/png" href="/favicon.png" />
13+
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
14+
<link rel="manifest" href="/manifest.webmanifest" />
1315

1416
<title>QuantDinger</title>
1517

16-
<!-- 防止页面缩放 -->
18+
<!-- Prevent accidental page zoom on mobile controls. -->
1719
<style>
1820
* {
1921
touch-action: manipulation;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"name": "quantdinger-mobile",
33
"private": true,
4-
"version": "1.0.5",
4+
"version": "2.0.1",
55
"license": "SEE LICENSE IN LICENSE",
66
"type": "module",
77
"scripts": {
88
"dev": "vite",
99
"build": "vite build",
1010
"preview": "vite preview",
1111
"cap:sync": "npx cap sync",
12+
"cap:assets": "npx @capacitor/assets generate --iconBackgroundColor #111114 --splashBackgroundColor #000000",
1213
"cap:android": "npx cap open android",
1314
"cap:ios": "npx cap open ios",
1415
"build:android": "vite build && npx cap sync android",

public/apple-touch-icon.png

25.4 KB
Loading

public/favicon.ico

746 Bytes
Binary file not shown.

public/favicon.png

4.92 KB
Loading

public/icon-192.png

28.3 KB
Loading

0 commit comments

Comments
 (0)