Skip to content

Commit 93f777e

Browse files
LeeEircxuwei-fit2cloud
authored andcommitted
perf: docker build ui
perf: fix arm build perf: fix action push perf: action ci
1 parent ce194ca commit 93f777e

File tree

2 files changed

+88
-7
lines changed

2 files changed

+88
-7
lines changed

.github/workflows/build_test.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: build-test-image-ghcr
2+
3+
run-name: 构建分支 ${{ github.event.inputs.branch }} 镜像并推送 ghcr.io ${{ github.event.inputs.tag }}
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
branch:
9+
description: 'Branch to build'
10+
default: 'main'
11+
required: true
12+
tag:
13+
description: 'Image Tag'
14+
default: 'latest'
15+
required: true
16+
17+
18+
jobs:
19+
build-and-push:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
ref: ${{ inputs.branch }}
26+
- name: Free Up GitHub Actions Ubuntu Runner Disk Space
27+
uses: jlumbroso/free-disk-space@main
28+
with:
29+
# This might remove tools that are actually needed, if set to "true" but frees about 6 GB
30+
tool-cache: false
31+
32+
# All of these default to true, but feel free to set to "false" if necessary for your workflow
33+
android: true
34+
dotnet: true
35+
haskell: true
36+
large-packages: false
37+
swap-storage: true
38+
- name: Setup Environment
39+
run: |
40+
echo "image_name=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/sqlbot" >> $GITHUB_ENV
41+
- name: Set up QEMU
42+
uses: docker/setup-qemu-action@v3
43+
with:
44+
image: tonistiigi/binfmt:qemu-v7.0.0-28
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
- name: Login to GitHub Container Registry
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.repository_owner }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Build and push multi-arch image
56+
uses: docker/build-push-action@v6
57+
with:
58+
platforms: linux/amd64,linux/arm64
59+
push: true
60+
provenance: false
61+
file: Dockerfile
62+
tags: ${{ env.image_name }}:${{ inputs.tag }}

Dockerfile

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
# Build sqlbot
22
FROM ghcr.io/1panel-dev/maxkb-vector-model:v1.0.1 AS vector-model
3-
FROM registry.cn-qingdao.aliyuncs.com/dataease/sqlbot-base:latest AS sqlbot-builder
3+
FROM --platform=${BUILDPLATFORM} registry.cn-qingdao.aliyuncs.com/dataease/sqlbot-base:latest AS sqlbot-ui-builder
4+
ENV SQLBOT_HOME=/opt/sqlbot
5+
ENV APP_HOME=${SQLBOT_HOME}/app
6+
ENV UI_HOME=${SQLBOT_HOME}/frontend
7+
ENV DEBIAN_FRONTEND=noninteractive
8+
9+
RUN mkdir -p ${APP_HOME} ${UI_HOME}
10+
11+
COPY frontend /tmp/frontend
12+
RUN cd /tmp/frontend && npm install && npm run build && mv dist ${UI_HOME}/dist
413

14+
15+
FROM registry.cn-qingdao.aliyuncs.com/dataease/sqlbot-base:latest AS sqlbot-builder
516
# Set build environment variables
617
ENV PYTHONUNBUFFERED=1
718
ENV SQLBOT_HOME=/opt/sqlbot
@@ -18,10 +29,7 @@ RUN mkdir -p ${APP_HOME} ${UI_HOME}
1829

1930
WORKDIR ${APP_HOME}
2031

21-
COPY frontend /tmp/frontend
22-
23-
RUN cd /tmp/frontend; npm install; npm run build; mv dist ${UI_HOME}/dist
24-
32+
COPY --from=sqlbot-ui-builder ${UI_HOME} ${UI_HOME}
2533
# Install dependencies
2634
RUN test -f "./uv.lock" && \
2735
--mount=type=cache,target=/root/.cache/uv \
@@ -33,16 +41,27 @@ COPY ./backend ${APP_HOME}
3341

3442
# Final sync to ensure all dependencies are installed
3543
RUN --mount=type=cache,target=/root/.cache/uv \
36-
uv sync --extra cpu
44+
uv sync --extra cpu
3745

3846
# Build g2-ssr
3947
FROM registry.cn-qingdao.aliyuncs.com/dataease/sqlbot-base:latest AS ssr-builder
4048

4149
WORKDIR /app
4250

51+
# Install build dependencies
52+
RUN apt-get update && apt-get install -y --no-install-recommends \
53+
build-essential python3 pkg-config \
54+
libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev \
55+
libpixman-1-dev libfreetype6-dev \
56+
&& rm -rf /var/lib/apt/lists/*
57+
58+
# configure npm
59+
RUN npm config set fund false \
60+
&& npm config set audit false \
61+
&& npm config set progress false
62+
4363
COPY g2-ssr/app.js g2-ssr/package.json /app/
4464
COPY g2-ssr/charts/* /app/charts/
45-
4665
RUN npm install
4766

4867
# Runtime stage

0 commit comments

Comments
 (0)