forked from BadWinniePooh/weight-tracking
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (47 loc) · 1.45 KB
/
Dockerfile
File metadata and controls
64 lines (47 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
FROM node:22-alpine AS base
# Install dependencies for Prisma
RUN apk add --no-cache libc6-compat openssl wget
# Set the working directory
WORKDIR /app
# Copy package.json and package-lock.json
FROM base AS deps
COPY package*.json ./
RUN npm ci
# Build stage
FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Generate Prisma Client
RUN npx prisma generate
# Build the Next.js application
RUN npm run build
# Production stage
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Disable telemetry
ENV NEXT_TELEMETRY_DISABLED=1
# Create a non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy the built application
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# Copy Prisma files
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --from=builder /app/src/generated ./src/generated
# Copy entrypoint script
COPY docker-entrypoint.sh ./
# Ensure script has Unix line endings and is executable
RUN sed -i 's/\r$//' docker-entrypoint.sh && chmod +x docker-entrypoint.sh
# Create directory for SQLite database
RUN mkdir -p /app/data && chown -R nextjs:nodejs /app/data
VOLUME /app/data
# Expose port for Next.js
EXPOSE 3000
USER nextjs
# Use the entrypoint script
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["node", "server.js"]