From 2f6e3da6f2485317a23d8d98beafbf5e295b725f Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 12:09:52 +0900 Subject: [PATCH 01/19] wip: add directory check --- .github/workflows/lint-and-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint-and-build.yml b/.github/workflows/lint-and-build.yml index 5e10c384..855e3f97 100644 --- a/.github/workflows/lint-and-build.yml +++ b/.github/workflows/lint-and-build.yml @@ -97,6 +97,8 @@ jobs: curl -L -o temp.zip https://github.com/turtton/volglass-docs/archive/refs/heads/main.zip 7z x temp.zip cp -r volglass-docs-main/posts . + ls . + ls posts - name: Build uses: docker/build-push-action@v4 From f01d133d18b281e78fd96c3813a7562879c6b07a Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 12:20:36 +0900 Subject: [PATCH 02/19] refactor: the target of replace more explicitly --- src/pages/[...id].tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/[...id].tsx b/src/pages/[...id].tsx index d2377bfe..d46385b0 100644 --- a/src/pages/[...id].tsx +++ b/src/pages/[...id].tsx @@ -125,7 +125,7 @@ export async function getStaticPaths(): Promise<{ }> { clearPublicDir(); const directoryData = getDirectoryData(); - const searchIndex = getSearchIndex() + const searchIndex = getSearchIndex(); const slugs = await initCache( JSON.stringify(directoryData), JSON.stringify(searchIndex), @@ -138,7 +138,7 @@ export async function getStaticPaths(): Promise<{ ); // TODO allows to put in image files in `posts` directory const paths = slugs.map((p) => ({ - params: { id: p.replace("/", "").split("/") }, + params: { id: p.replace(/^\//, "").split("/") }, })); return { paths, From eabe39bd3d49dcb3d73687b9321847ed291893f5 Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 12:20:52 +0900 Subject: [PATCH 03/19] wip: change directory output command --- .github/workflows/lint-and-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint-and-build.yml b/.github/workflows/lint-and-build.yml index 855e3f97..ea96bd3e 100644 --- a/.github/workflows/lint-and-build.yml +++ b/.github/workflows/lint-and-build.yml @@ -97,8 +97,8 @@ jobs: curl -L -o temp.zip https://github.com/turtton/volglass-docs/archive/refs/heads/main.zip 7z x temp.zip cp -r volglass-docs-main/posts . - ls . - ls posts + tree . + tree posts - name: Build uses: docker/build-push-action@v4 From db38fbf992476f0a45dd94406ab10bde747bcd61 Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 12:31:59 +0900 Subject: [PATCH 04/19] build: change node version --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 480b33a5..cb479418 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile # Install dependencies only when needed -FROM node:19-alpine AS deps +FROM node:18-alpine AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat WORKDIR /app @@ -13,7 +13,7 @@ RUN yarn global add pnpm && pnpm i # Rebuild the source code only when needed -FROM node:19-bullseye-slim AS builder +FROM node:18-bullseye-slim AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . @@ -32,7 +32,7 @@ RUN yarn global add pnpm && pnpm run build # RUN npm run build # Production image, copy all the files and run next -FROM node:19-alpine AS runner +FROM node:18-alpine AS runner WORKDIR /app ENV NODE_ENV production From 6b9ad408df07338e49ea30511140c605f08809ea Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 12:48:10 +0900 Subject: [PATCH 05/19] refactor: replace id param --- src/pages/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index b35963e8..bcb7172e 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -6,7 +6,11 @@ import Home, { export const Index = (prop: Prop) => Home(prop); +/** + * This id is related to FIRST_PAGE() + * {@link FIRST_PAGE} + */ export const getStaticProps = async () => - getDefaultStaticProps({ params: { id: [FIRST_PAGE()] } }); + getDefaultStaticProps({ params: { id: ["README"] } }); export default Index; From 0255723599ad81d974d0761c39fdbbbb6d9a53ff Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 12:52:46 +0900 Subject: [PATCH 06/19] docs: fix function style in comment --- src/pages/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index bcb7172e..d30fcb87 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -7,7 +7,7 @@ import Home, { export const Index = (prop: Prop) => Home(prop); /** - * This id is related to FIRST_PAGE() + * This id is related to [...id]$FIRST_PAGE() * {@link FIRST_PAGE} */ export const getStaticProps = async () => From 9656a9289aaf38d60e4da0236b20e18651caac77 Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 12:53:07 +0900 Subject: [PATCH 07/19] ci: remove directory structure output --- .github/workflows/lint-and-build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/lint-and-build.yml b/.github/workflows/lint-and-build.yml index ea96bd3e..5e10c384 100644 --- a/.github/workflows/lint-and-build.yml +++ b/.github/workflows/lint-and-build.yml @@ -97,8 +97,6 @@ jobs: curl -L -o temp.zip https://github.com/turtton/volglass-docs/archive/refs/heads/main.zip 7z x temp.zip cp -r volglass-docs-main/posts . - tree . - tree posts - name: Build uses: docker/build-push-action@v4 From b6db08da595e8efb8f360a74f1c98643dea9db6b Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 12:55:11 +0900 Subject: [PATCH 08/19] revert: undo process --- src/pages/index.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pages/index.tsx b/src/pages/index.tsx index d30fcb87..b35963e8 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -6,11 +6,7 @@ import Home, { export const Index = (prop: Prop) => Home(prop); -/** - * This id is related to [...id]$FIRST_PAGE() - * {@link FIRST_PAGE} - */ export const getStaticProps = async () => - getDefaultStaticProps({ params: { id: ["README"] } }); + getDefaultStaticProps({ params: { id: [FIRST_PAGE()] } }); export default Index; From 9e9dd77defc7eb200edfb803d40b2d6ea7967fee Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 12:57:49 +0900 Subject: [PATCH 09/19] wip: remove empty slug from path --- src/pages/[...id].tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/[...id].tsx b/src/pages/[...id].tsx index d46385b0..8c8997e5 100644 --- a/src/pages/[...id].tsx +++ b/src/pages/[...id].tsx @@ -139,7 +139,10 @@ export async function getStaticPaths(): Promise<{ // TODO allows to put in image files in `posts` directory const paths = slugs.map((p) => ({ params: { id: p.replace(/^\//, "").split("/") }, - })); + })).filter((p) => p.params.id.length !== 0 && p.params.id[0] !== ""); + console.log("path result"); + paths.forEach(p => { + console.log(p.params.id);}) return { paths, fallback: false, From c739c4eebf3fdddca4d5e8f3e565f11122336b52 Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 13:10:11 +0900 Subject: [PATCH 10/19] ci: re-add directory check --- .github/workflows/lint-and-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint-and-build.yml b/.github/workflows/lint-and-build.yml index 5e10c384..f582593f 100644 --- a/.github/workflows/lint-and-build.yml +++ b/.github/workflows/lint-and-build.yml @@ -97,6 +97,7 @@ jobs: curl -L -o temp.zip https://github.com/turtton/volglass-docs/archive/refs/heads/main.zip 7z x temp.zip cp -r volglass-docs-main/posts . + tree . - name: Build uses: docker/build-push-action@v4 From ca38c4ac282578bac9824ef45bcb33aeabfb08a6 Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 13:13:31 +0900 Subject: [PATCH 11/19] ci: change step --- .github/workflows/lint-and-build.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint-and-build.yml b/.github/workflows/lint-and-build.yml index f582593f..770fd0c9 100644 --- a/.github/workflows/lint-and-build.yml +++ b/.github/workflows/lint-and-build.yml @@ -89,16 +89,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Download template contents run: | curl -L -o temp.zip https://github.com/turtton/volglass-docs/archive/refs/heads/main.zip 7z x temp.zip cp -r volglass-docs-main/posts . tree . - + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - name: Build uses: docker/build-push-action@v4 with: From 3bcbe1a756f7e8ad86563c39fd6f13c1dcfc3696 Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 13:19:06 +0900 Subject: [PATCH 12/19] build: make explicit a copy of the post folder --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index cb479418..d663f3c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ FROM node:18-bullseye-slim AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . +COPY posts ./ # Install java11 RUN apt -q update && apt -y -q install --no-install-recommends openjdk-11-jdk-headless From 666023b307218ece83b46ec9b04dcda60f7563a7 Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 21:04:12 +0900 Subject: [PATCH 13/19] ci: change contents permissions --- .github/workflows/lint-and-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-and-build.yml b/.github/workflows/lint-and-build.yml index 770fd0c9..338b3a26 100644 --- a/.github/workflows/lint-and-build.yml +++ b/.github/workflows/lint-and-build.yml @@ -94,7 +94,8 @@ jobs: curl -L -o temp.zip https://github.com/turtton/volglass-docs/archive/refs/heads/main.zip 7z x temp.zip cp -r volglass-docs-main/posts . - tree . + chmod 766 posts/* + ls -lah - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build From 8f279b1572585428b98213106455e40daa2eeee8 Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 21:20:29 +0900 Subject: [PATCH 14/19] chore: change README.md file ignore rule --- .dockerignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 72e9aa42..b8587fdd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,6 +2,6 @@ Dockerfile .dockerignore node_modules npm-debug.log -README.md +/README.md .next .git \ No newline at end of file From c9a63500133350f04d18e8e5b17c882e592edd5f Mon Sep 17 00:00:00 2001 From: turtton Date: Fri, 31 Mar 2023 21:22:14 +0900 Subject: [PATCH 15/19] ci: add chown command --- .github/workflows/lint-and-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-and-build.yml b/.github/workflows/lint-and-build.yml index 338b3a26..89670832 100644 --- a/.github/workflows/lint-and-build.yml +++ b/.github/workflows/lint-and-build.yml @@ -94,8 +94,9 @@ jobs: curl -L -o temp.zip https://github.com/turtton/volglass-docs/archive/refs/heads/main.zip 7z x temp.zip cp -r volglass-docs-main/posts . + chown $USER posts/* chmod 766 posts/* - ls -lah + ls -lah posts - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build From 46177f336b1798f2a78f13ea6d962d7c107ea2c3 Mon Sep 17 00:00:00 2001 From: turtton Date: Mon, 3 Apr 2023 12:20:40 +0900 Subject: [PATCH 16/19] ci: add context option --- .github/workflows/lint-and-build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-and-build.yml b/.github/workflows/lint-and-build.yml index 89670832..bf5fe45e 100644 --- a/.github/workflows/lint-and-build.yml +++ b/.github/workflows/lint-and-build.yml @@ -103,4 +103,5 @@ jobs: uses: docker/build-push-action@v4 with: file: ./Dockerfile - push: false \ No newline at end of file + push: false + context: . \ No newline at end of file From 52f6616d475598bf2c2bfac2353e6bf6088510b7 Mon Sep 17 00:00:00 2001 From: turtton Date: Mon, 3 Apr 2023 12:31:57 +0900 Subject: [PATCH 17/19] refactor: cleanup codes --- .github/workflows/lint-and-build.yml | 9 ++++----- src/pages/[...id].tsx | 3 --- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/lint-and-build.yml b/.github/workflows/lint-and-build.yml index bf5fe45e..0337476d 100644 --- a/.github/workflows/lint-and-build.yml +++ b/.github/workflows/lint-and-build.yml @@ -89,16 +89,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Download template contents run: | curl -L -o temp.zip https://github.com/turtton/volglass-docs/archive/refs/heads/main.zip 7z x temp.zip cp -r volglass-docs-main/posts . - chown $USER posts/* - chmod 766 posts/* - ls -lah posts - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + - name: Build uses: docker/build-push-action@v4 with: diff --git a/src/pages/[...id].tsx b/src/pages/[...id].tsx index 8c8997e5..e639a592 100644 --- a/src/pages/[...id].tsx +++ b/src/pages/[...id].tsx @@ -140,9 +140,6 @@ export async function getStaticPaths(): Promise<{ const paths = slugs.map((p) => ({ params: { id: p.replace(/^\//, "").split("/") }, })).filter((p) => p.params.id.length !== 0 && p.params.id[0] !== ""); - console.log("path result"); - paths.forEach(p => { - console.log(p.params.id);}) return { paths, fallback: false, From 2cce69d88f566d1d555ad6513945914780d1ee03 Mon Sep 17 00:00:00 2001 From: turtton Date: Mon, 3 Apr 2023 12:32:40 +0900 Subject: [PATCH 18/19] revert: image node version --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d663f3c5..990a4df5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile # Install dependencies only when needed -FROM node:18-alpine AS deps +FROM node:19-alpine AS deps # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat WORKDIR /app @@ -13,7 +13,7 @@ RUN yarn global add pnpm && pnpm i # Rebuild the source code only when needed -FROM node:18-bullseye-slim AS builder +FROM node:19-bullseye-slim AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . @@ -33,7 +33,7 @@ RUN yarn global add pnpm && pnpm run build # RUN npm run build # Production image, copy all the files and run next -FROM node:18-alpine AS runner +FROM node:19-alpine AS runner WORKDIR /app ENV NODE_ENV production From d77081877e7773e63c47ab8f110e196e73f99620 Mon Sep 17 00:00:00 2001 From: turtton Date: Mon, 3 Apr 2023 12:33:37 +0900 Subject: [PATCH 19/19] revert: remove redundant COPY --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 990a4df5..480b33a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,6 @@ FROM node:19-bullseye-slim AS builder WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . -COPY posts ./ # Install java11 RUN apt -q update && apt -y -q install --no-install-recommends openjdk-11-jdk-headless