From 33f498af70042e0cce8d0de828b1ae7bea8a7fba Mon Sep 17 00:00:00 2001 From: Mira Kristipati Date: Tue, 11 Jun 2024 12:53:17 -0400 Subject: [PATCH] reload on commit should work now? --- Dockerfile | 19 +++---------------- src/pages/rebuild.ts | 8 ++++++++ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 55541f9..8603a48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,9 @@ FROM node:lts-alpine AS base -RUN npm i -g pnpm +RUN npm i -g pnpm && \ + apk add git WORKDIR /app -COPY package.json pnpm-lock.yaml ./ - -FROM base as prod-deps -RUN pnpm install -P - -FROM base as build-deps -RUN pnpm install - -FROM build-deps as build COPY . . -RUN pnpm run build - - -FROM base as runtime -COPY --from=prod-deps /app/node_modules . -COPY --from=build /app/dist ./dist +RUN pnpm install && pnpm build ENV HOST=0.0.0.0 ENV PORT=4321 diff --git a/src/pages/rebuild.ts b/src/pages/rebuild.ts index ba3bafd..2d854f5 100644 --- a/src/pages/rebuild.ts +++ b/src/pages/rebuild.ts @@ -1,3 +1,11 @@ +import { exec } from "node:child_process"; +import util from "node:util"; +const exec_promise = util.promisify(exec); export async function POST({ params, request }) { console.log(params, request); + let result = await exec_promise("git pull && pnpm build").then((out, err) => { + return { out, err }; + }); + console.log("Outside", result); + return new Response(JSON.stringify(result)); }