From 336399e76b6d493af0568a2a549e68b8cc369034 Mon Sep 17 00:00:00 2001 From: liuweiqing Date: Sun, 11 Feb 2024 14:28:03 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20docker=E5=B0=9D=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker.yml | 25 ++++++++++++++++++++++++ Dockerfile | 37 ++++++++++++++++++++++++++++++++++++ app/globals.css | 8 ++++++++ components/QuillEditor.tsx | 18 ++++-------------- components/Settings.tsx | 6 +++++- 5 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..0d9210cd --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,25 @@ +name: Node.js CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..55e00ba3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,37 @@ +# 使用 Node.js 官方镜像作为构建环境 +FROM node:alpine as builder + +# 设置工作目录 +WORKDIR /app + +# 复制 package.json 和 package-lock.json (或 yarn.lock) +COPY package*.json ./ +# 如果使用yarn,并有yarn.lock文件,也可以复制 +# COPY package.json yarn.lock ./ + +# 安装项目依赖 +RUN npm install +# 如果使用 yarn,可以用 RUN yarn install 代替 + +# 复制项目文件到工作目录 +COPY . . + +# 构建应用 +RUN npm run build + +# 使用 Node.js 镜像运行应用 +FROM node:alpine + +# 设置工作目录 +WORKDIR /app + +# 只复制构建产出和package.json到新的镜像中 +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/package.json ./package.json + +# 暴露端口 +EXPOSE 3000 + +# 启动 Next.js 应用 +CMD ["npm", "start"] diff --git a/app/globals.css b/app/globals.css index c242b97f..9daaedd7 100644 --- a/app/globals.css +++ b/app/globals.css @@ -110,6 +110,14 @@ /* 可以添加其他样式来美化组件,如背景色、阴影等 */ } +#editor { + /* width: calc(100vw - 20px); */ + min-height: 250px; + max-height: 400px; + overflow-y: auto; + border: 1px solid #ccc; +} + /* 适配手机样式 */ @media (max-width: 768px) { #editor { diff --git a/components/QuillEditor.tsx b/components/QuillEditor.tsx index 2cef65c3..d67fd13a 100644 --- a/components/QuillEditor.tsx +++ b/components/QuillEditor.tsx @@ -361,7 +361,7 @@ const QEditor = () => { } return ( -
+