Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
kienvc authored Feb 2, 2024
1 parent 4218570 commit 8bd515a
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
# Build BASE
FROM node:18-alpine as BASE
FROM node:18-alpine AS deps
RUN apk add --no-cache libc6-compat
WORKDIR /app

COPY package.json yarn.lock ./
RUN yarn install
RUN yarn --frozen-lockfile

# Build Image
FROM node:18-alpine AS BUILD
WORKDIR /app
# FROM node:18-alpine AS builder
# WORKDIR /app
# COPY --from=deps /app/node_modules ./node_modules
COPY . .

RUN apk add --no-cache curl
RUN curl -sf https://gobinaries.com/tj/node-prune | sh -s -- -b /usr/local/bin
# ENV NEXT_TELEMETRY_DISABLED 1

COPY --from=BASE /app/node_modules ./node_modules
COPY . .
RUN yarn build
RUN cd .next/standalone
RUN node-prune

# Build production
FROM node:18-alpine AS PRODUCTION
ENV NODE_ENV production
WORKDIR /app
# FROM node:18-alpine AS runner
# WORKDIR /app

# COPY --from=BUILD /app/.env.example ./.env
COPY --from=BUILD /app/public ./public
COPY --from=BUILD /app/next.config.js ./
COPY --from=BUILD /app/.next/standalone ./
COPY --from=BUILD /app/.next/static ./.next/static
# ENV NODE_ENV production
# ENV NEXT_TELEMETRY_DISABLED 1

RUN mkdir -p /app/public/social-images/
# RUN addgroup --system --gid 1001 nodejs
# RUN adduser --system --uid 1001 nextjs

# COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
# COPY --from=builder /app/node_modules ./node_modules
# COPY --from=builder /app/package.json ./package.json

# USER nextjs

EXPOSE 3000
CMD ["node", "server.js"]

ENV PORT 3000

CMD ["yarn", "start"]

0 comments on commit 8bd515a

Please sign in to comment.