-
-
Notifications
You must be signed in to change notification settings - Fork 98
/
Dockerfile
62 lines (50 loc) · 1.7 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
FROM node:20-slim AS deps
RUN corepack enable && \
rm -f /usr/local/bin/pnpm && \
rm -f /usr/local/bin/pnpx && \
npm install -g pnpm
WORKDIR /app
COPY package*.json ./
COPY pnpm-lock.yaml ./
COPY .env .env.local ./
RUN pnpm install
FROM node:20-slim AS build_image
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
#COPY --from=deps /app/package-lock.json ./
COPY --from=deps /app/pnpm-lock.yaml ./
COPY . .
# Install OpenSSL
RUN apt-get update -y && \
apt-get install -y openssl libssl-dev && \
npm install -g pnpm && \
pnpm prisma generate && \
pnpm prisma db push && \
pnpm prisma db seed && \
pnpm run build
FROM node:20-slim AS production
ENV NODE_ENV production
RUN addgroup --system nodejs && \
adduser --system --ingroup nodejs nextjs
RUN apt-get update -y && \
apt-get install -y openssl libssl-dev
WORKDIR /app
#COPY --from=build_image --chown=nextjs:nodejs /app/package.json /app/package-lock.json ./
COPY --from=build_image --chown=nextjs:nodejs /app/package.json ./
COPY --from=build_image --chown=nextjs:nodejs /app/pnpm-lock.yaml ./
COPY --from=build_image --chown=nextjs:nodejs /app/node_modules ./node_modules
COPY --from=build_image --chown=nextjs:nodejs /app/public ./public
COPY --from=build_image --chown=nextjs:nodejs /app/.next ./.next
COPY --from=build_image --chown=nextjs:nodejs /app/.env ./.env
COPY --from=build_image --chown=nextjs:nodejs /app/.env.local ./.env.local
# Switch to root to install pnpm
USER root
# Install pnpm globally
RUN npm install -g pnpm
# Switch back to nextjs user
USER nextjs
EXPOSE 3000
# Check if pnpm is installed
RUN pnpm --version || echo "pnpm not found"
# Use npx to run pnpm
CMD [ "npx", "pnpm", "start" ]