Improve Docker image
This commit is contained in:
20
Dockerfile
20
Dockerfile
@@ -4,12 +4,6 @@ WORKDIR /opt/app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
FROM node:16-alpine AS builder
|
||||
ENV NODE_ENV=production
|
||||
WORKDIR /opt/app
|
||||
COPY . .
|
||||
COPY --from=deps /opt/app/node_modules ./node_modules
|
||||
RUN npm run build
|
||||
|
||||
FROM node:16-alpine AS script-builder
|
||||
WORKDIR /opt/app
|
||||
@@ -23,17 +17,9 @@ RUN ncc build index.ts
|
||||
FROM node:16-alpine AS runner
|
||||
WORKDIR /opt/app
|
||||
ENV NODE_ENV=production
|
||||
COPY --from=builder /opt/app/next.config.js ./
|
||||
COPY --from=builder /opt/app/public ./public
|
||||
COPY --from=builder /opt/app/.next ./.next
|
||||
COPY --from=builder /opt/app/node_modules ./node_modules
|
||||
COPY . .
|
||||
COPY --from=deps /opt/app/node_modules ./node_modules
|
||||
COPY --from=script-builder /opt/app/.setup/dist/index.js ./scripts/setup.js
|
||||
|
||||
COPY .env.example .env
|
||||
COPY entrypoint.sh .
|
||||
RUN apk add --no-cache --upgrade bash
|
||||
RUN ["chmod", "+x", "./entrypoint.sh"]
|
||||
ENTRYPOINT ["./entrypoint.sh"]
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["node_modules/.bin/next", "start"]
|
||||
CMD npm run build && npm start
|
||||
Reference in New Issue
Block a user