- Auto-run migrations when db module loads - Copy drizzle migrations folder to Docker image - Generate missing color column migration - Fixes 500 errors on /api/candles and /api/annotations in Docker
44 lines
1 KiB
Docker
44 lines
1 KiB
Docker
# Build stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
|
|
RUN npm ci
|
|
|
|
COPY . .
|
|
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:20-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies for better-sqlite3
|
|
RUN apk add --no-cache python3 make g++
|
|
|
|
RUN addgroup -g 1001 -S nodejs && adduser -S nextjs -u 1001
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
# Copy node_modules for native dependencies like better-sqlite3
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
|
|
|
# Copy drizzle migrations
|
|
COPY --from=builder --chown=nextjs:nodejs /app/drizzle ./drizzle
|
|
|
|
RUN mkdir -p /app/public /app/data && chown -R nextjs:nodejs /app/public /app/data
|
|
|
|
ENV NODE_ENV=production PORT=3000 HOSTNAME=0.0.0.0
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD wget --no-verbose --tries=1 --spider http://localhost:3000/api/health || exit 1
|
|
|
|
CMD ["node", "server.js"]
|