optimize docker
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
.git
|
||||
.github
|
||||
.cursor
|
||||
.next
|
||||
node_modules
|
||||
coverage
|
||||
dist
|
||||
build
|
||||
out
|
||||
|
||||
# Environment and local tooling
|
||||
.env*
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
# Logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
# Docs and metadata
|
||||
README*
|
||||
*.md
|
||||
+15
-18
@@ -1,3 +1,5 @@
|
||||
# syntax=docker/dockerfile:1.7
|
||||
|
||||
FROM node:20-alpine AS base
|
||||
|
||||
# Change Alpine repo
|
||||
@@ -13,37 +15,32 @@ RUN apk add --no-cache tzdata && \
|
||||
echo "Asia/Tehran" > /etc/timezone
|
||||
|
||||
WORKDIR /app
|
||||
ENV TZ=Asia/Tehran
|
||||
|
||||
FROM base AS deps
|
||||
RUN apk add --no-cache libc6-compat git
|
||||
RUN apk add --no-cache libc6-compat
|
||||
COPY package*.json ./
|
||||
RUN npm ci --legacy-peer-deps --ignore-scripts --loglevel info
|
||||
RUN --mount=type=cache,target=/root/.npm \
|
||||
npm ci --legacy-peer-deps --no-audit --no-fund --loglevel warn
|
||||
|
||||
FROM base AS builder
|
||||
WORKDIR /build
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
RUN npm run build && npm ci --omit=dev --legacy-peer-deps --ignore-scripts --loglevel info
|
||||
RUN npm run build
|
||||
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV NODE_ENV=production \
|
||||
NEXT_TELEMETRY_DISABLED=1 \
|
||||
PORT=3000 \
|
||||
HOSTNAME=0.0.0.0
|
||||
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
RUN mkdir .next && chown appuser:appgroup .next
|
||||
RUN mkdir -p .next && chown appuser:appgroup .next
|
||||
|
||||
COPY --from=builder --chown=appuser:appgroup /build/.next/standalone ./
|
||||
COPY --from=builder --chown=appuser:appgroup /build/.next/static ./.next/static
|
||||
COPY --from=builder --chown=appuser:appgroup /build/public ./public
|
||||
COPY --from=builder --chown=appuser:appgroup /build/package.json ./package.json
|
||||
COPY --from=builder --chown=appuser:appgroup /app/.next/standalone ./
|
||||
COPY --from=builder --chown=appuser:appgroup /app/.next/static ./.next/static
|
||||
COPY --from=builder --chown=appuser:appgroup /app/public ./public
|
||||
|
||||
USER appuser
|
||||
|
||||
EXPOSE 3000
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
ENV NEXT_PUBLIC_API_BASE_URL=https://api.danakcorp.com/
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
Reference in New Issue
Block a user