From 126e748955dcc5c975bdbadf90de9dbaeff7cd4d Mon Sep 17 00:00:00 2001 From: Hare Date: Tue, 3 Sep 2024 06:04:28 +0900 Subject: [PATCH 1/4] chore: Remove articles subproject --- articles | 1 - 1 file changed, 1 deletion(-) delete mode 160000 articles diff --git a/articles b/articles deleted file mode 160000 index 1af78ed..0000000 --- a/articles +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1af78edd4c4e4e5b3834303e19f3507998019825 From 700304b466690692e49ca9fad836a540fda5be75 Mon Sep 17 00:00:00 2001 From: Hare Date: Tue, 3 Sep 2024 06:52:35 +0900 Subject: [PATCH 2/4] chore: Add key files to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 4aeef5b..cb27c21 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ node_modules postgres +key +key.pub + # Output .output .vercel From 8a5d09d6159a9754e9798803371339596750c6fc Mon Sep 17 00:00:00 2001 From: Hare Date: Tue, 3 Sep 2024 06:52:49 +0900 Subject: [PATCH 3/4] chore: Update Dockerfile to clone blog articles repository --- docker/app.Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docker/app.Dockerfile b/docker/app.Dockerfile index c8c9bef..b684e14 100644 --- a/docker/app.Dockerfile +++ b/docker/app.Dockerfile @@ -15,11 +15,13 @@ RUN npm run build # For Run FROM node:22-slim -RUN apt-get update && apt-get install -y git - WORKDIR /app -COPY ./articles ./articles +COPY ./key ./key +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* && \ + mkdir -p ~/.ssh && \ + ssh-keyscan -t rsa gitea.hareworks.net >> ~/.ssh/known_hosts && \ + git -c core.sshCommand="ssh -i ./key -F /dev/null" clone git@gitea.hareworks.net:Hare/blog-articles.git articles COPY --from=builder /app/build ./build COPY --from=builder /app/package.json . From 04f9bd5e9920e84757e36e9d32a56b0b6ac66cea Mon Sep 17 00:00:00 2001 From: Hare Date: Tue, 3 Sep 2024 06:58:13 +0900 Subject: [PATCH 4/4] chore: Update git command to use custom SSH key for pulling articles --- src/lib/server/database/init_db.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/server/database/init_db.ts b/src/lib/server/database/init_db.ts index cd090f8..bcb5202 100644 --- a/src/lib/server/database/init_db.ts +++ b/src/lib/server/database/init_db.ts @@ -7,7 +7,7 @@ import { execSync } from 'child_process'; export default async function init(db: Postgres) { if (fs.existsSync('./articles/')) { console.log('Pulling articles from git..'); - const stdout = execSync('git pull', { cwd: './articles/' }); + const stdout = execSync('git -c core.sshCommand="ssh -i ../key -F /dev/null" pull', { cwd: './articles/' }); console.log(stdout.toString()); }