forked from pdovhomilja/nextcrm-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (26 loc) · 931 Bytes
/
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
FROM node:20.9.0-alpine AS deps
WORKDIR /app
COPY package*.json ./
RUN npm install
# Copy .env and .env.local before the build stage
COPY .env .env.local ./
FROM node:20.9.0-alpine AS BUILD_IMAGE
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npx prisma generate && npx prisma db push && npx prisma db seed && npm run build
RUN rm -rf node_modules
RUN npm install
FROM node:20.9.0-alpine
ENV NODE_ENV production
RUN addgroup -g 1001 -S nodejs
RUN adduser -S nextjs -u 1001
WORKDIR /app
COPY --from=BUILD_IMAGE --chown=nextjs:nodejs /app/package.json /app/package-lock.json ./
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
USER nextjs
EXPOSE 3000
CMD [ "npm", "start" ]
#docker build --build-arg ENV_FILE=.env -t myimage .