-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdockerfile
65 lines (48 loc) · 1.34 KB
/
dockerfile
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
FROM node:18-alpine AS builder
# Install necessary build tools and Python dependencies
RUN apk add --no-cache \
libc6-compat \
python3 \
python3-dev \
py3-pip \
make \
g++ \
build-base \
linux-headers \
libusb-dev \
eudev-dev
# Install python3 distutils
RUN pip3 install setuptools --break-system-packages
# Install pnpm and node-gyp
RUN npm install -g pnpm@7 node-gyp
WORKDIR /app
# Copy package files
COPY package.json pnpm-lock.yaml ./
# Create .npmrc with configurations
RUN echo "node-linker=hoisted" > .npmrc && \
echo "shamefully-hoist=true" >> .npmrc && \
echo "strict-peer-dependencies=false" >> .npmrc && \
echo "auto-install-peers=true" >> .npmrc
# Install dependencies
RUN pnpm install --no-frozen-lockfile --unsafe-perm
# Copy source code
COPY . .
# Build the application
RUN pnpm run build
# Production image
FROM node:18-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# Copy necessary files
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
RUN chmod -R 777 ./public
USER nextjs
EXPOSE 3000
ENV PORT 3000
CMD ["node", "server.js"]