From 1104217070398c1dd7f40b39004c38801dd80891 Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Mon, 27 Apr 2026 16:58:44 +0800 Subject: [PATCH] upd:dockerfile --- Dockerfile | 66 +++++++++++++++--------------------------------------- 1 file changed, 18 insertions(+), 48 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f41ba9..7ae36c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,62 +1,32 @@ -# Stage 1: Build -FROM oven/bun:1.3 AS build - -# Install build dependencies for native modules -RUN apt-get update && apt-get install -y \ - python3 \ - make \ - g++ \ - && rm -rf /var/lib/apt/lists/* - -# Set the working directory +FROM oven/bun:1 AS base WORKDIR /app -# Copy package files -COPY package.json bun.lock* ./ - # Install dependencies +FROM base AS deps +COPY package.json bun.lock ./ RUN bun install --frozen-lockfile -# Copy the rest of the application code -COPY . . - -# Use .env.example as default env for build -RUN cp .env.example .env - # Generate Prisma client -RUN bun x prisma generate +FROM deps AS prisma +COPY prisma ./prisma +RUN bunx prisma generate -# Generate API types -RUN bun run gen:api - -# Build the application frontend +# Build frontend (Vite → dist/) +FROM prisma AS builder +COPY . . RUN bun run build -# Stage 2: Runtime -FROM oven/bun:1.3-slim AS runtime - -# Set environment variables -ENV NODE_ENV=production - -# Install runtime dependencies -RUN apt-get update && apt-get install -y \ - postgresql-client \ - && rm -rf /var/lib/apt/lists/* - -# Set the working directory +# Runtime +FROM base AS runner WORKDIR /app -# Copy necessary files from build stage -COPY --from=build /app/package.json ./ -COPY --from=build /app/tsconfig.json ./ -COPY --from=build /app/dist ./dist -COPY --from=build /app/generated ./generated -COPY --from=build /app/src ./src -COPY --from=build /app/node_modules ./node_modules -COPY --from=build /app/prisma ./prisma +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/prisma ./prisma +COPY --from=builder /app/src ./src +COPY --from=builder /app/dist ./dist +COPY --from=builder /app/package.json ./ -# Expose the port +ENV NODE_ENV=production EXPOSE 3000 -# Start the application -CMD ["bun", "start"] +CMD ["bun", "src/index.tsx"] \ No newline at end of file