From 0e6f405ec4415b5febb4d1754edbf442df4163ed Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Fri, 10 Jan 2025 21:20:33 +0500 Subject: [PATCH] optimize container build --- .build/prod/bun.Dockerfile | 17 +++-------------- .dockerignore | 10 ++++++++++ package.json | 7 ++++--- 3 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 .dockerignore diff --git a/.build/prod/bun.Dockerfile b/.build/prod/bun.Dockerfile index bd9bb03..f9e29d3 100644 --- a/.build/prod/bun.Dockerfile +++ b/.build/prod/bun.Dockerfile @@ -1,29 +1,18 @@ FROM oven/bun:1.1.42-debian AS builder WORKDIR /var/www/html - ENV NEXT_TELEMETRY_DISABLED=1 -ENV DATABASE_URL="postgresql://dummy:dummy@dummy:5432/dummy" - -COPY package.json package-lock.json ./ -COPY prisma ./prisma/ - -RUN bun install --frozen-lockfile - -RUN bunx prisma generate COPY . . - +RUN bun install --frozen-lockfile +RUN bunx prisma generate RUN bun run build FROM oven/bun:1.1.42-debian WORKDIR /var/www/html - COPY --from=builder /var/www/html/package.json ./ COPY --from=builder /var/www/html/node_modules ./node_modules COPY --from=builder /var/www/html/.next ./.next COPY --from=builder /var/www/html/public ./public COPY --from=builder /var/www/html/prisma ./prisma - VOLUME /var/www/html - -CMD bun start +CMD ["bun", "start"] diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1a18842 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.git +.next +node_modules +npm-debug.log +README.md +.env* +.dockerignore +Dockerfile +docker-compose.yml +compose.yml diff --git a/package.json b/package.json index ffa2ced..3449071 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,12 @@ "private": true, "scripts": { "dev": "next dev --turbopack", - "build": "bunx prisma migrate deploy && bunx prisma generate && bunx prisma db push && next build", + "build": "next build", "start": "next start", "lint": "next lint", "studio": "bunx prisma studio", - "push": "bunx prisma db push" + "push": "bunx prisma db push", + "db-setup": "bunx prisma migrate deploy && bunx prisma generate && bunx prisma db push" }, "prisma": { "seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts" @@ -66,4 +67,4 @@ "ts-node": "^10.9.2", "typescript": "^5.7.2" } -} \ No newline at end of file +}