From 9e03d2bdb026fe21a58c029292d0ab1a026b97ed Mon Sep 17 00:00:00 2001 From: TheRealToxicDev Date: Mon, 22 Dec 2025 03:44:25 -0700 Subject: [PATCH] feat(update): nixpacks stuff --- Dockerfile | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ nixpacks.toml | 5 +++-- 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..27d382e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +# Stage 1: Install dependencies and build +FROM oven/bun:1 AS builder + +WORKDIR /app + +# Install git for submodule handling +RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* + +# Copy package files first for better caching +COPY package.json bun.lock* ./ +COPY prisma ./prisma/ + +# Install dependencies +RUN bun install --frozen-lockfile + +# Copy the rest of the application +COPY . . + +# Initialize git submodules if .gitmodules exists +RUN if [ -f .gitmodules ]; then \ + git init && \ + git submodule update --init --recursive; \ + fi + +# Generate Prisma client +RUN bunx prisma generate + +# Build the application +ENV NEXT_TELEMETRY_DISABLED=1 +ENV NODE_ENV=production +RUN bun run build + +# Stage 2: Production image +FROM oven/bun:1-slim AS runner + +WORKDIR /app + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 + +# Create non-root user +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nextjs + +# Copy built assets +COPY --from=builder /app/public ./public +COPY --from=builder /app/.next/standalone ./ +COPY --from=builder /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3009 + +ENV PORT=3009 +ENV HOSTNAME="0.0.0.0" + +CMD ["bun", "start"] diff --git a/nixpacks.toml b/nixpacks.toml index ccd972d..38f9545 100644 --- a/nixpacks.toml +++ b/nixpacks.toml @@ -1,3 +1,4 @@ [phases.setup] -nixPkgs = ["bun", "nodejs_20"] -includeNode = false \ No newline at end of file +nixPkgs = ["bun", "nodejs_20", "git"] +includeNode = false +cmds = ["git submodule update --init --recursive"] \ No newline at end of file