59 lines
1.9 KiB
Docker
59 lines
1.9 KiB
Docker
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Copy SDK to a location outside the app source
|
|
COPY sdk/ /opt/encryptid-sdk/
|
|
|
|
# Install dependencies
|
|
COPY package.json package-lock.json* ./
|
|
RUN sed -i 's|"file:../encryptid-sdk"|"file:/opt/encryptid-sdk"|' package.json
|
|
RUN npm install --legacy-peer-deps
|
|
|
|
# Copy source files explicitly (avoid copying sdk/)
|
|
COPY src/ ./src/
|
|
COPY prisma/ ./prisma/
|
|
COPY sync-server/ ./sync-server/
|
|
COPY public/ ./public/
|
|
COPY next.config.ts tsconfig.json postcss.config.mjs entrypoint.sh ./
|
|
|
|
# Generate Prisma client and build
|
|
RUN npx prisma generate
|
|
RUN npm run build
|
|
|
|
# ─── Production ───────────────────────────────────────────
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
RUN addgroup --system --gid 1001 nodejs && \
|
|
adduser --system --uid 1001 nextjs
|
|
|
|
# Copy Next.js standalone output
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
COPY --from=builder /app/public ./public
|
|
|
|
# Copy sync server (plain JS, no compilation needed)
|
|
COPY --from=builder /app/sync-server/src/index.js ./sync-server/index.js
|
|
COPY --from=builder /app/node_modules/yjs ./node_modules/yjs
|
|
COPY --from=builder /app/node_modules/y-websocket ./node_modules/y-websocket
|
|
COPY --from=builder /app/node_modules/y-protocols ./node_modules/y-protocols
|
|
COPY --from=builder /app/node_modules/lib0 ./node_modules/lib0
|
|
COPY --from=builder /app/node_modules/ws ./node_modules/ws
|
|
COPY --from=builder /app/node_modules/lodash.debounce ./node_modules/lodash.debounce
|
|
|
|
# Copy Prisma client
|
|
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
|
|
COPY --from=builder /app/node_modules/@prisma ./node_modules/@prisma
|
|
|
|
# Copy entrypoint
|
|
COPY --from=builder /app/entrypoint.sh ./entrypoint.sh
|
|
RUN chmod +x entrypoint.sh
|
|
|
|
USER nextjs
|
|
EXPOSE 3000 4444
|
|
|
|
ENTRYPOINT ["./entrypoint.sh"]
|
|
CMD ["node", "server.js"]
|