Skip to content

Commit

Permalink
Merge pull request #72 from jembi/fix/production-docker-prisma-setup
Browse files Browse the repository at this point in the history
Fix production build
  • Loading branch information
BMartinos authored Sep 19, 2024
2 parents 6967b80 + 281203b commit de0f676
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions docker/production/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ COPY --from=deps /app/node_modules ./node_modules
COPY . .
# This will do the trick, use the corresponding env file for each environment.
COPY .env.production.example .env.production
RUN npm run build --turbo

RUN yarn build && \
yarn next-swagger-doc-cli next-swagger-doc.json

# 3. Production image, copy all the files and run next
FROM base AS runner
Expand All @@ -37,6 +39,12 @@ COPY --from=builder /app/public ./public
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder /app/prisma ./prisma

# Ensure logs directory is created under the correct permissions
RUN mkdir logs && \
chmod 755 logs && \
chown nextjs:nodejs logs

USER nextjs

Expand All @@ -45,4 +53,4 @@ EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"

CMD ["node", "server.js"]
CMD ["sh", "-c", "npx --yes prisma migrate deploy --schema=./prisma/schema.prisma && node server.js"]
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7012,4 +7012,4 @@ zenscroll@^4.0.2:
zod@^3.22.4, zod@^3.23.8:
version "3.23.8"
resolved "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d"
integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==
integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==

0 comments on commit de0f676

Please sign in to comment.