docker compose
This commit is contained in:
@@ -1,56 +1,8 @@
|
||||
# build front-end
|
||||
FROM node:lts-alpine AS frontend
|
||||
|
||||
RUN npm install pnpm -g
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./package.json /app
|
||||
|
||||
COPY ./pnpm-lock.yaml /app
|
||||
|
||||
RUN pnpm install
|
||||
|
||||
COPY . /app
|
||||
|
||||
RUN pnpm run build
|
||||
|
||||
# build backend
|
||||
FROM node:lts-alpine as backend
|
||||
|
||||
RUN npm install pnpm -g
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY /service/package.json /app
|
||||
|
||||
COPY /service/pnpm-lock.yaml /app
|
||||
|
||||
RUN pnpm install
|
||||
|
||||
COPY /service /app
|
||||
|
||||
RUN pnpm build
|
||||
|
||||
# service
|
||||
FROM node:lts-alpine
|
||||
|
||||
RUN npm install pnpm -g
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY /service/package.json /app
|
||||
|
||||
COPY /service/pnpm-lock.yaml /app
|
||||
|
||||
RUN pnpm install --production && rm -rf /root/.npm /root/.pnpm-store /usr/local/share/.cache /tmp/*
|
||||
|
||||
COPY /service /app
|
||||
|
||||
COPY --from=frontend /app/dist /app/public
|
||||
|
||||
COPY --from=backend /app/build /app/build
|
||||
|
||||
EXPOSE 3002
|
||||
|
||||
CMD ["pnpm", "run", "prod"]
|
||||
FROM nginx:1.27-alpine
|
||||
|
||||
COPY ./docker/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
COPY ./dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
20
chatgpt-web-frontend/docker/nginx/default.conf
Normal file
20
chatgpt-web-frontend/docker/nginx/default.conf
Normal file
@@ -0,0 +1,20 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_pass http://chatgpt-web-backend:7080/api/;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
<script setup lang='ts'>
|
||||
import { computed, useAttrs } from 'vue'
|
||||
import { Icon } from '@iconify/vue'
|
||||
import type { IconifyIcon } from '@iconify/vue'
|
||||
|
||||
interface Props {
|
||||
icon?: string
|
||||
icon?: string | IconifyIcon
|
||||
}
|
||||
|
||||
defineProps<Props>()
|
||||
const props = defineProps<Props>()
|
||||
|
||||
const attrs = useAttrs()
|
||||
|
||||
@@ -17,5 +18,5 @@ const bindAttrs = computed<{ class: string; style: string }>(() => ({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Icon :icon="icon" v-bind="bindAttrs" />
|
||||
<Icon :icon="props.icon ?? ''" v-bind="bindAttrs" />
|
||||
</template>
|
||||
|
||||
@@ -2,7 +2,12 @@ import { ss } from '@/utils/storage'
|
||||
|
||||
const LOCAL_NAME = 'promptStore'
|
||||
|
||||
export type PromptList = []
|
||||
export interface PromptItem {
|
||||
key: string
|
||||
value: string
|
||||
}
|
||||
|
||||
export type PromptList = PromptItem[]
|
||||
|
||||
export interface PromptStore {
|
||||
promptList: PromptList
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import type { PromptStore } from './helper'
|
||||
import type { PromptList, PromptStore } from './helper'
|
||||
import { getLocalPromptList, setLocalPromptList } from './helper'
|
||||
|
||||
export const usePromptStore = defineStore('prompt-store', {
|
||||
state: (): PromptStore => getLocalPromptList(),
|
||||
|
||||
actions: {
|
||||
updatePromptList(promptList: []) {
|
||||
updatePromptList(promptList: PromptList) {
|
||||
this.$patch({ promptList })
|
||||
setLocalPromptList({ promptList })
|
||||
},
|
||||
|
||||
@@ -15,6 +15,7 @@ import { useBasicLayout } from '@/hooks/useBasicLayout'
|
||||
import { useChatStore, usePromptStore } from '@/store'
|
||||
import { fetchChatAPIProcess } from '@/api'
|
||||
import { t } from '@/locales'
|
||||
import type { PromptItem } from '@/store/modules/prompt/helper'
|
||||
|
||||
let controller = new AbortController()
|
||||
|
||||
@@ -44,7 +45,7 @@ const inputRef = ref<Ref | null>(null)
|
||||
const promptStore = usePromptStore()
|
||||
|
||||
// 使用storeToRefs,保证store修改后,联想部分能够重新渲染
|
||||
const { promptList: promptTemplate } = storeToRefs<any>(promptStore)
|
||||
const { promptList: promptTemplate } = storeToRefs(promptStore) as { promptList: Ref<PromptItem[]> }
|
||||
|
||||
// 未知原因刷新页面,loading 状态不会重置,手动重置
|
||||
dataSources.value.forEach((item, index) => {
|
||||
|
||||
@@ -33,7 +33,7 @@ export default defineConfig((env) => {
|
||||
plugins: setupPlugins(viteEnv),
|
||||
server: {
|
||||
host: '0.0.0.0',
|
||||
port: 1025,
|
||||
port: 3002,
|
||||
open: false,
|
||||
proxy: {
|
||||
'/api': {
|
||||
|
||||
Reference in New Issue
Block a user