浏览代码

Merge remote-tracking branch 'origin/main' into feat/mantine-ui

AykutSarac 2 年之前
父节点
当前提交
8fe3d3b3cd
共有 3 个文件被更改,包括 19 次插入9 次删除
  1. 9 1
      .github/workflows/nextjs.yml
  2. 4 5
      Dockerfile
  3. 6 3
      next.config.js

+ 9 - 1
.github/workflows/nextjs.yml

@@ -35,7 +35,7 @@ jobs:
         run: |
           if [ -f "${{ github.workspace }}/yarn.lock" ]; then
             echo "manager=yarn" >> $GITHUB_OUTPUT
-            echo "command=install" >> $GITHUB_OUTPUT
+            echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
             echo "runner=yarn" >> $GITHUB_OUTPUT
             exit 0
           elif [ -f "${{ github.workspace }}/package.json" ]; then
@@ -52,6 +52,14 @@ jobs:
         with:
           node-version: "16"
           cache: ${{ steps.detect-package-manager.outputs.manager }}
+      - name: Cache node_modules
+        uses: actions/cache@v3
+        with:
+          path: |
+            ~/.npm
+            ~/.cache/yarn
+          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}
+          restore-keys: ${{ runner.os }}-node-
       - name: Setup Pages
         uses: actions/configure-pages@v3
         with:

+ 4 - 5
Dockerfile

@@ -1,11 +1,10 @@
 # Builder
-FROM node:14-buster as builder
+FROM node:14-alpine as builder
 WORKDIR /src
-COPY . /src
-RUN yarn install --legacy-peer-deps
-RUN yarn run build
+COPY . /src/
+RUN npm ci && npm run build
 
 # App
 FROM nginxinc/nginx-unprivileged
-COPY --from=builder /src/out /app
+COPY --chown=nginx:nginx --from=builder /src/out /app
 COPY default.conf /etc/nginx/conf.d/default.conf

+ 6 - 3
next.config.js

@@ -1,6 +1,9 @@
-const withBundleAnalyzer = require("@next/bundle-analyzer")({
-  enabled: process.env.ANALYZE === "true",
-});
+const withBundleAnalyzer =
+  process.env.ANALYZE === "true"
+    ? require("@next/bundle-analyzer")({
+        enabled: process.env.ANALYZE === "true",
+      })()
+    : x => x;
 
 /**
  * @type {import('next').NextConfig}