From 664669584996a10001273b94ad0a05f06178e9cb Mon Sep 17 00:00:00 2001 From: Void Date: Thu, 16 Feb 2023 13:39:07 +0800 Subject: [PATCH] Add Dockerfile (#33) * add Dockerfile * update Readme.md * Fixed : Docker log file * Update vite.config.ts --- .dockerignore | 6 ++++++ Dockerfile | 19 +++++++++++++++++++ README.md | 10 ++++++++++ start.sh | 11 +++++++++++ 4 files changed, 46 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 start.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5078fcd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +node_modules +Dockerfile +.git +.husky +.github +.vscode diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..253cf70 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:lts + +# copy resource +RUN mkdir /app +COPY ./ /app +WORKDIR /app + +# build +RUN npm install pnpm -g +RUN pnpm bootstrap +WORKDIR /app/service +RUN pnpm install +WORKDIR /app + +EXPOSE 1002 +EXPOSE 3002 + +CMD ["/bin/bash","./start.sh"] + diff --git a/README.md b/README.md index 7d8b4c7..14cc4bd 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,16 @@ pnpm build pnpm prod ``` +## Docker build & run + +``` +docker rm -f $(docker ps -a| grep marlkiller/chatgpt-web | awk '{print $1}') +docker rmi $(docker images 'marlkiller/chatgpt-web' -q) + +docker build -t marlkiller/chatgpt-web . +docker run -p 1002:1002 marlkiller/chatgpt-web +``` + PS: 不进行打包,直接在服务器上运行 `pnpm start` 也可 ### 网页 diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..8440c6c --- /dev/null +++ b/start.sh @@ -0,0 +1,11 @@ + +cd ./service +nohup pnpm start > service.log & +echo "Start service complete!" + + +cd .. +echo "" > front.log +nohup pnpm dev > front.log & +echo "Start front complete!" +tail -f front.log