From 796e4a78315db8f8a8131a424237aad071182d17 Mon Sep 17 00:00:00 2001 From: static Date: Sat, 28 Dec 2024 13:05:59 +0900 Subject: [PATCH] =?UTF-8?q?Dockerfile=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 31 +++++++++++++++++++++++++++++++ Dockerfile | 29 +++++++++++++++++++++++++++++ src/lib/server/loadenv.ts | 5 ++++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4853a6e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,31 @@ +.git +node_modules + +# Output +.output +.vercel +.netlify +.wrangler +/.svelte-kit +/build +/drizzle + +# OS +.DS_Store +Thumbs.db + +# VSCode +/.vscode + +# Env +.env +.env.* +!.env.example +!.env.test + +# Vite +vite.config.js.timestamp-* +vite.config.ts.timestamp-* + +# SQLite +*.db diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d22f972 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Build Stage +FROM node:18-alpine AS build +WORKDIR /app + +RUN npm install -g pnpm@8 + +COPY pnpm-lock.yaml . +RUN pnpm fetch + +COPY . . +RUN pnpm install --offline +RUN pnpm build + +# Deploy Stage +FROM node:18-alpine +WORKDIR /app + +RUN npm install -g pnpm@8 + +COPY pnpm-lock.yaml . +RUN pnpm fetch --prod + +COPY package.json . +RUN pnpm install --offline --prod + +COPY --from=build /app/build ./build + +EXPOSE 3000 +CMD ["node", "./build/index.js"] diff --git a/src/lib/server/loadenv.ts b/src/lib/server/loadenv.ts index 83f4514..8df1e19 100644 --- a/src/lib/server/loadenv.ts +++ b/src/lib/server/loadenv.ts @@ -1,6 +1,9 @@ +import { building } from "$app/environment"; import { env } from "$env/dynamic/private"; -if (!env.JWT_SECRET) throw new Error("JWT_SECRET is not set"); +if (!building) { + if (!env.JWT_SECRET) throw new Error("JWT_SECRET is not set"); +} export default { databaseUrl: env.DATABASE_URL || "local.db",