Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
5 changes: 3 additions & 2 deletions nixpacks.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[phases.setup]
nixPkgs = ["bun", "nodejs_20"]
includeNode = false
nixPkgs = ["bun", "nodejs_20", "git"]
includeNode = false
cmds = ["git submodule update --init --recursive"]