feat: Added multi-architecture image building and service startup instructions, upgraded Node image and package manager
This commit is contained in:
@@ -0,0 +1,67 @@
|
|||||||
|
name: Build and Push Docker Image
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
jobs:
|
||||||
|
build-app:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- service_name: ui
|
||||||
|
file: frontend/Dockerfile
|
||||||
|
context: ./frontend
|
||||||
|
arch: amd64
|
||||||
|
platform: linux/amd64
|
||||||
|
- service_name: app
|
||||||
|
file: docker/Dockerfile.app
|
||||||
|
context: .
|
||||||
|
arch: amd64
|
||||||
|
platform: linux/amd64
|
||||||
|
- service_name: docreader
|
||||||
|
file: docker/Dockerfile.docreader
|
||||||
|
context: .
|
||||||
|
arch: amd64
|
||||||
|
platform: linux/amd64
|
||||||
|
- service_name: ui
|
||||||
|
file: frontend/Dockerfile
|
||||||
|
context: ./frontend
|
||||||
|
arch: arm64
|
||||||
|
platform: linux/arm64
|
||||||
|
- service_name: app
|
||||||
|
file: docker/Dockerfile.app
|
||||||
|
context: .
|
||||||
|
arch: arm64
|
||||||
|
platform: linux/arm64
|
||||||
|
- service_name: docreader
|
||||||
|
file: docker/Dockerfile.docreader
|
||||||
|
context: .
|
||||||
|
arch: arm64
|
||||||
|
platform: linux/arm64
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build ${{ matrix.service_name }} Image
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
file: ${{ matrix.file }}
|
||||||
|
context: ${{ matrix.context }}
|
||||||
|
tags: ${{ secrets.DOCKERHUB_USERNAME }}/weknora-${{ matrix.service_name }}:${{ matrix.arch }}-latest
|
||||||
|
build-args: |
|
||||||
|
PLATFORM=${{ matrix.platform }}
|
||||||
@@ -116,6 +116,18 @@ cp .env.example .env
|
|||||||
make start-all
|
make start-all
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### ③ 启动服务备选
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 启动 ollama 服务 (可选)
|
||||||
|
ollama serve > /dev/null 2>&1 &
|
||||||
|
|
||||||
|
# 根据系统架构(amd64 或者 arm64)启动服务
|
||||||
|
ARCH=amd64 docker compose up -d
|
||||||
|
# 或
|
||||||
|
ARCH=arm64 docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
#### ④ 停止服务
|
#### ④ 停止服务
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -116,6 +116,18 @@ cp .env.example .env
|
|||||||
make start-all
|
make start-all
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### ③ Start the services (backup)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Start ollama services (Optional)
|
||||||
|
ollama serve > /dev/null 2>&1 &
|
||||||
|
|
||||||
|
# Start the service according to the system architecture (amd64 or arm64)
|
||||||
|
ARCH=amd64 docker compose up -d
|
||||||
|
# Or
|
||||||
|
ARCH=arm64 docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
#### ④ Stop the services
|
#### ④ Stop the services
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,5 @@
|
|||||||
# 构建阶段
|
# 构建阶段
|
||||||
FROM node:20-alpine as build-stage
|
FROM node:24-alpine as build-stage
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -11,13 +11,14 @@ ENV VITE_IS_DOCKER=true
|
|||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
|
||||||
# 安装依赖
|
# 安装依赖
|
||||||
RUN npm install
|
RUN corepack enable
|
||||||
|
RUN pnpm install
|
||||||
|
|
||||||
# 复制项目文件
|
# 复制项目文件
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# 构建应用
|
# 构建应用
|
||||||
RUN npm run build
|
RUN pnpm run build
|
||||||
|
|
||||||
# 生产阶段
|
# 生产阶段
|
||||||
FROM nginx:stable-alpine as production-stage
|
FROM nginx:stable-alpine as production-stage
|
||||||
|
|||||||
Reference in New Issue
Block a user