Files
root aaddfc7bfc
Deploy feedback demo / deploy (push) Failing after 4m26s
API 적용 최초 배포
2026-09-01 17:12:46 +09:00

76 lines
2.8 KiB
Docker

# This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
# Make sure you update both files!
ARG NPM_REGISTRY=https://registry.npmjs.org
ARG APP_NEXT_PUBLIC_API_BASE_URL=https://feedback.hmac.kr
ARG APP_NEXT_PUBLIC_FEEDBACK_ONLY=true
FROM node:24.14.1-alpine AS base
ARG NPM_REGISTRY
ENV COREPACK_NPM_REGISTRY=${NPM_REGISTRY} \
npm_config_registry=${NPM_REGISTRY}
FROM base AS builder
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
# Set working directory
WORKDIR /app
RUN npm install -g turbo
COPY . .
RUN turbo prune --scope=web --docker
# Add lockfile and package.json's of isolated subworkspace
FROM base AS installer
ARG APP_NEXT_PUBLIC_API_BASE_URL
ARG APP_NEXT_PUBLIC_FEEDBACK_ONLY
RUN apk add --no-cache libc6-compat
RUN apk --no-cache add --virtual .builds-deps build-base python3
WORKDIR /app
RUN corepack enable
# First install the dependencies (as they change less often)
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
RUN pnpm install --frozen-lockfile --ignore-scripts --fetch-retries 10 --fetch-timeout 120000
RUN pnpm rebuild bcrypt esbuild @swc/core sharp
# Build the project
COPY --from=builder /app/out/full/ .
COPY turbo.json ./
RUN printf 'NEXT_PUBLIC_API_BASE_URL=%s\nNEXT_PUBLIC_FEEDBACK_ONLY=%s\n' "$APP_NEXT_PUBLIC_API_BASE_URL" "$APP_NEXT_PUBLIC_FEEDBACK_ONLY" > /app/apps/web/.env.production
RUN SKIP_ENV_VALIDATION=true pnpm exec turbo run build --filter=web...
FROM base AS runner
WORKDIR /app
# install usermod and change node user to 1001
RUN echo http://dl-2.alpinelinux.org/alpine/edge/community/ >> /etc/apk/repositories
RUN apk --no-cache add shadow
RUN groupmod -g 1001 node \
&& usermod -u 1001 -g 1001 node
# Don't run production as root
RUN addgroup --system --gid 3000 nodejs
RUN adduser --system -G nodejs --uid 1000 nextjs -D
USER nextjs
COPY --from=installer /app/apps/web/next-i18next.config.js .
COPY --from=installer /app/apps/web/next.config.js .
COPY --from=installer /app/apps/web/package.json .
COPY --from=installer /app/apps/web/.env.production ./apps/web/.env.production
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public
COPY --from=installer --chown=nextjs:nodejs /app/apps/web/entrypoint.sh ./apps/web/entrypoint.sh
ENTRYPOINT ["apps/web/entrypoint.sh"]
CMD ["node", "apps/web/server.js"]