Skip to content

Commit

Permalink
build: 支持arm镜像
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Aug 29, 2023
1 parent 28d3347 commit ba23fb8
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 113 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/coverage

# next.js
/.next/
/out/

# production
Expand Down
68 changes: 50 additions & 18 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,60 @@
name: Build Docker Image
name: Build Docker Image Multi-Platform

on:
push:
branches:
- dev

jobs:
github:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
# jobs:
# github:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1

- name: Login to github registry
uses: actions-hub/docker/login@master
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# - name: Login to github registry
# uses: actions-hub/docker/login@master
# env:
# DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
# DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

- name: Build :latest
if: success()
run: docker build -t weaigc/bingo:latest .
# - name: Build :latest
# if: success()
# run: docker buildx --platform linux/amd64,linux/arm64 -t weaigc/bingo:latest .

- name: Push to docker hub :latest
if: success()
uses: actions-hub/docker@master
# - name: Push to docker hub :latest
# if: success()
# uses: actions-hub/docker@master
# with:
# args: push weaigc/bingo:latest
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
- run: |
npm install
npm run build
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
args: push weaigc/bingo:latest
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: weaigc/bingo:latest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Sync to Hugging Face hub
name: Sync to Hugging Face hub x64
on:
workflow_run:
workflows: ["Build Docker Image"]
workflows: ["Build Docker Image Multi-Platform"]
types:
- completed

Expand All @@ -22,5 +22,7 @@ jobs:
cd huggingface
git config user.name hf4all
git config user.email hf4all@gmail.com
git commit -am "auto build" --amend
echo "Last deploy time: $(date)" > DEPLOY_INFO.txt
git add DEPLOY_INFO.txt
git commit -am "auto deploy $(date)"
git push https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$HF_USERNAME/$SPACE_NAME main -f
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FROM node:18

FROM node:16

ARG DEBIAN_FRONTEND=noninteractive

Expand All @@ -23,14 +22,17 @@ WORKDIR $HOME/app
# where available (npm@5+)
COPY --chown=user package*.json $HOME/app/

RUN npm install
COPY --chown=user .next $HOME/app/

RUN npm install --verbose

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app/
#COPY --chown=user . $HOME/app/

RUN npm run build && rm -rf src
#RUN npm run build && rm -rf src

ENV PORT 7860

EXPOSE 7860

CMD npm start
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes
4 changes: 1 addition & 3 deletions src/components/chat-header.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import LogoIcon from '@/assets/images/bing.png'
import Image from 'next/image'

export function ChatHeader() {
return (
<div className="flex flex-col items-center justify-center">
<Image alt="logo" src={LogoIcon} width={60}/>
<img alt="logo" src="./favicon.png" width={60}/>
<div className="mt-4 mb-8 font-bold header-title">必应是 AI 支持的网上助手</div>
</div>
)
Expand Down
163 changes: 83 additions & 80 deletions src/lib/bots/bing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,71 +23,71 @@ type Params = SendMessageParams<{ bingConversationStyle: BingConversationStyle,
const getOptionSets = (conversationStyle: BingConversationStyle) => {
return {
[BingConversationStyle.Creative]: [
"nlu_direct_response_filter",
"deepleo",
"disable_emoji_spoken_text",
"responsible_ai_policy_235",
"enablemm",
"dv3sugg",
"machine_affinity",
"autosave",
"iyxapbing",
"iycapbing",
"h3imaginative",
"adsredirecturl",
"bof107v2",
"streamw",
"rctechalwlst",
"agicert",
"cdxedtgnd",
"eredirecturl",
"clgalileo",
"gencontentv3"
'nlu_direct_response_filter',
'deepleo',
'disable_emoji_spoken_text',
'responsible_ai_policy_235',
'enablemm',
'dv3sugg',
'machine_affinity',
'autosave',
'iyxapbing',
'iycapbing',
'h3imaginative',
'clgalileo',
'gencontentv3',
'adsredirecturl',
'bof107v2',
'streamw',
'rctechalwlst',
'agicert',
'cdxedtgnd',
'eredirecturl'
],
[BingConversationStyle.Balanced]: [
"nlu_direct_response_filter",
"deepleo",
"disable_emoji_spoken_text",
"responsible_ai_policy_235",
"enablemm",
"dv3sugg",
"machine_affinity",
"autosave",
"iyxapbing",
"iycapbing",
"galileo",
"adsredirecturl",
"bof107v2",
"streamw",
"rctechalwlst",
"agicert",
"cdxedtgnd",
"eredirecturl",
"saharagenconv5",
"fluxhint",
"glfluxv13"
'nlu_direct_response_filter',
'deepleo',
'disable_emoji_spoken_text',
'responsible_ai_policy_235',
'enablemm',
'dv3sugg',
'machine_affinity',
'autosave',
'iyxapbing',
'iycapbing',
'galileo',
'adsredirecturl',
'bof107v2',
'streamw',
'rctechalwlst',
'agicert',
'cdxedtgnd',
'eredirecturl',
'saharagenconv5',
'fluxhint',
'glfluxv13'
],
[BingConversationStyle.Precise]: [
"nlu_direct_response_filter",
"deepleo",
"disable_emoji_spoken_text",
"responsible_ai_policy_235",
"enablemm",
"dv3sugg",
"machine_affinity",
"autosave",
"iyxapbing",
"iycapbing",
"h3precise",
"adsredirecturl",
"bof107v2",
"streamw",
"rctechalwlst",
"agicert",
"cdxedtgnd",
"eredirecturl",
"clgalileo",
"gencontentv3"
'nlu_direct_response_filter',
'deepleo',
'disable_emoji_spoken_text',
'responsible_ai_policy_235',
'enablemm',
'dv3sugg',
'machine_affinity',
'autosave',
'iyxapbing',
'iycapbing',
'h3precise',
'adsredirecturl',
'bof107v2',
'streamw',
'rctechalwlst',
'agicert',
'cdxedtgnd',
'eredirecturl',
'clgalileo',
'gencontentv3'
]
}[conversationStyle]
}
Expand Down Expand Up @@ -128,30 +128,31 @@ export class BingWebBot {
'InternalLoaderMessage',
'Progress',
'RenderCardRequest',
'AdsQuery',
'SemanticSerp',
'GenerateContentQuery',
'SearchQuery',
],
sliceIds: [
"629adsredir",
"edi",
"divkorbl2p",
"wrapuxslimc",
"wrapnoins",
"sydconfigoptt",
"0731ziv2s0",
"0824cntors0",
"816bof107v2",
"806log2sphs0",
"0518logoss0",
"0529streamw",
"streamw",
"178gentech",
"824fluxhi52s0",
"0825agicert",
"804cdxedtgd",
"727udtupms0",
"727nrprdrt5"
'629adsredir',
'edi',
'divkorbl2p',
'wrapuxslimc',
'wrapnoins',
'sydconfigoptt',
'0731ziv2s0',
'0824cntors0',
'816bof107v2',
'806log2sphs0',
'0518logoss0',
'0529streamw',
'streamw',
'178gentech',
'824fluxhi52s0',
'0825agicert',
'804cdxedtgd',
'727udtupms0',
'727nrprdrt5'
],
isStartOfSession: conversation.invocationId === 0,
message: {
Expand All @@ -164,6 +165,8 @@ export class BingWebBot {
conversationId: conversation.conversationId,
conversationSignature: conversation.conversationSignature,
participant: { id: conversation.clientId },
spokenTextMode: 'None',
tone: conversation.conversationStyle,
},
],
invocationId: conversation.invocationId.toString(),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}) : ''
debug(`try ${count+1}`, endpoint, headers['x-forwarded-for'])
const response = await fetch(`https://${endpoint || 'www.bing.com'}/turing/conversation/create?${query}`, { method: 'GET', headers })
debug('status', headers, response.status, response.url)
debug('status', response.status, response.url)
if (response.status === 200) {
const json = await response.json().catch(e => {})
if (!json?.conversationSignature) {
Expand Down

0 comments on commit ba23fb8

Please sign in to comment.