WIP
This commit is contained in:
parent
d28cce3fba
commit
2ec2f61904
7 changed files with 6533 additions and 2 deletions
74
multistage.dockerfile
Normal file
74
multistage.dockerfile
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
FROM --platform=linux/amd64 node:18-bullseye-slim as node
|
||||
FROM --platform=linux/amd64 oven/bun:1.0.1 as bun
|
||||
|
||||
### DEPENDENCIES
|
||||
|
||||
FROM node AS deps
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# RUN apk add --no-cache libc6-compat openssl1.1-compat
|
||||
RUN apt-get update && apt-get install -y openssl=1.1.1n-0+deb11u5
|
||||
|
||||
COPY prisma ./prisma
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
|
||||
RUN npm ci --frozen-lockfile
|
||||
|
||||
### BUILDER
|
||||
|
||||
FROM node AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=deps /app/prisma ./prisma
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
RUN SKIP_ENV_VALIDATION=1 npm run build
|
||||
|
||||
### RUNNER
|
||||
|
||||
# FROM base AS runner
|
||||
|
||||
FROM bun AS runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production \
|
||||
NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y ca-certificates openssl=1.1.1n-0+deb11u5 && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Required for `npx prisma migrate deploy`
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
|
||||
# Required for `npx prisma db seed`
|
||||
COPY --from=builder /app/content ./content
|
||||
COPY --from=builder /app/src/content/training.ts ./src/content/training.ts
|
||||
COPY --from=builder /app/src/server/db.ts ./src/server/db.ts
|
||||
COPY --from=builder /app/src/env.mjs ./src/env.mjs
|
||||
|
||||
# Required for Next.js
|
||||
COPY --from=builder /app/next.config.mjs ./
|
||||
COPY --from=builder /app/tsconfig.json ./
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
|
||||
USER nextjs
|
||||
EXPOSE 3000
|
||||
ENV PORT 3000
|
||||
|
||||
CMD ["bun", "run", "server.js"]
|
||||
Reference in a new issue