diff --git a/.dockerignore b/.dockerignore index 9958964..66cd9f8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,4 +11,13 @@ node_modules coverage npm-debug.log .dockerignore -Dockerfile* \ No newline at end of file +Dockerfile* +tsconfig.tsbuildinfo +next-env.d.ts +public/tower_game-master/src +public/tower_game-master/package.json +public/tower_game-master/package-lock.json +public/the-cube-master/src +public/the-cube-master/package.json +public/the-cube-master/package-lock.json +public/the-cube-master/rollup.config.* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 783d7a3..19bfc51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +# syntax=docker/dockerfile:1 + FROM node:20-alpine AS base # Change Alpine repo @@ -13,37 +15,33 @@ FROM node:20-alpine AS base # echo "Asia/Tehran" > /etc/timezone WORKDIR /app +ENV NEXT_TELEMETRY_DISABLED=1 \ + npm_config_update_notifier=false FROM base AS deps -RUN apk add --no-cache libc6-compat -COPY package*.json ./ +COPY package.json package-lock.json ./ RUN --mount=type=cache,target=/root/.npm \ - npm ci --legacy-peer-deps --loglevel info + npm ci --legacy-peer-deps --prefer-offline FROM base AS builder COPY --from=deps /app/node_modules ./node_modules COPY . . -RUN npm run build +ARG NEXT_PUBLIC_API_BASE_URL=https://api.danakcorp.com/ +ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL +RUN --mount=type=cache,target=/app/.next/cache \ + npm run build FROM base AS runner -WORKDIR /app - -ENV NODE_ENV=production -ENV NEXT_TELEMETRY_DISABLED=1 +ENV NODE_ENV=production \ + PORT=3000 \ + HOSTNAME=0.0.0.0 RUN addgroup -S appgroup && adduser -S appuser -G appgroup -RUN mkdir .next && chown appuser:appgroup .next +COPY --from=builder --chown=appuser:appgroup /app/public ./public 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 -COPY --from=builder --chown=appuser:appgroup /app/package.json ./package.json 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"]