-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathDockerfile
More file actions
94 lines (71 loc) · 2.75 KB
/
Copy pathDockerfile
File metadata and controls
94 lines (71 loc) · 2.75 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
FROM node:22-alpine AS base
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app
# Copy package files
COPY package.json package-lock.json* ./
# CACHEBUST forces npm install to re-run even when package files are unchanged
ARG CACHEBUST=1
RUN echo "Cache bust: $CACHEBUST" && npm install --legacy-peer-deps
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
# Copy the entire project
COPY . .
# Generate Prisma client
RUN npx prisma generate
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1
ENV CI_BUILD_MODE 1
ENV DOCKER_BUILD 1
# Build the app
RUN npm run build
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
# Install all dependencies to satisfy entrypoint requirements
COPY package.json package-lock.json* ./
RUN npm install --legacy-peer-deps
# Install Prisma client with exact version match
RUN npm uninstall prisma @prisma/client --legacy-peer-deps
RUN npm install prisma@6.7.0 @prisma/client@6.7.0 --legacy-peer-deps
# Install tsx explicitly
RUN npm install -g tsx
# Install esbuild for widget
RUN npm install esbuild --legacy-peer-deps
# Install JSDOC
RUN npm install -g jsdoc
# Add bash, nginx, and other dependencies for the entry script
RUN apk add --no-cache bash wget nginx
# Install nginx-agent from GitHub
RUN wget -q https://github.com/Changerawr/nginx-agent/archive/refs/heads/master.tar.gz -O /tmp/nginx-agent.tar.gz && \
mkdir -p /nginx-agent && \
tar -xzf /tmp/nginx-agent.tar.gz -C /nginx-agent --strip-components=1 && \
rm /tmp/nginx-agent.tar.gz && \
cd /nginx-agent && \
npm install --production
# Create nginx directories
RUN mkdir -p /etc/nginx/sites-enabled /etc/nginx/sites-available /etc/ssl/changerawr /var/log/nginx /var/lib/nginx/tmp /run/nginx
# Copy the entire project from the builder stage
COPY --from=builder /app .
# Copy maintenance page and server script
COPY scripts/maintenance/index.html ./index.html
COPY scripts/maintenance/server.js ./scripts/maintenance/server.js
# Copy nginx configuration
COPY nginx.conf /etc/nginx/nginx.conf
# Copy and make nginx reload script executable
COPY scripts/nginx-reload.sh /usr/local/bin/nginx-reload.sh
RUN chmod +x /usr/local/bin/nginx-reload.sh
# Ensure the entrypoint script is executable
RUN chmod +x ./docker-entrypoint.sh
EXPOSE 3000 80 443
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
# Use entrypoint for running the build scripts before starting the server
ENTRYPOINT ["/app/docker-entrypoint.sh"]
CMD ["npm", "start"]