Skip to content

Commit 8b9704b

Browse files
fix: docker (#352)
* fix: docker code smell from sonarcloud * fix: Make the docker works (will need to take more time to use standalone) --------- Co-authored-by: Ivan Dalmet <[email protected]>
1 parent 384e39e commit 8b9704b

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
.idea/
2626
.eslintcache
2727
.db
28+
.git
2829

2930
# debug
3031
npm-debug.log*

Dockerfile

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,22 @@
1-
# Install dependencies only when needed
2-
FROM node:16-alpine AS deps
1+
FROM node:18-alpine
32
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
43
RUN apk add --no-cache libc6-compat
54
RUN apk add --no-cache git
65
WORKDIR /app
76
COPY . .
87
RUN yarn install --frozen-lockfile
9-
10-
# Rebuild the source code only when needed
11-
FROM node:16-alpine AS builder
12-
RUN apk add --no-cache git
13-
WORKDIR /app
14-
COPY . .
15-
COPY --from=deps /app/node_modules ./node_modules
16-
RUN yarn build
17-
18-
# Production image, copy all the files and run next
19-
FROM node:16-alpine AS runner
20-
WORKDIR /app
21-
228
ENV NODE_ENV production
23-
9+
RUN yarn build
2410
RUN addgroup -g 1001 -S nodejs
2511
RUN adduser -S nextjs -u 1001
2612

27-
# You only need to copy next.config.js if you are NOT using the default configuration
28-
# COPY --from=builder /app/next.config.js ./
29-
COPY --from=builder /app/public ./public
30-
COPY --from=builder /app/package.json ./package.json
31-
32-
# Automatically leverage output traces to reduce image size
33-
# https://nextjs.org/docs/advanced-features/output-file-tracing
34-
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
35-
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
36-
3713
USER nextjs
3814

3915
EXPOSE 3000
4016

4117
ENV PORT 3000
4218

43-
# Next.js collects completely anonymous telemetry data about general usage.
4419
# Learn more here: https://nextjs.org/telemetry
45-
# Comment the following line in case you want to enable telemetry.
4620
ENV NEXT_TELEMETRY_DISABLED 1
4721

48-
CMD ["node", "server.js"]
22+
CMD ["yarn", "start"]

0 commit comments

Comments
 (0)