2022-05-24 12:13:49 +02:00
|
|
|
# Install dependencies only when needed
|
|
|
|
FROM node:16-alpine AS deps
|
|
|
|
# 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
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json yarn.lock ./
|
|
|
|
RUN yarn install --frozen-lockfile
|
2022-02-19 05:00:21 +01:00
|
|
|
|
2022-05-24 12:13:49 +02:00
|
|
|
# Rebuild the source code only when needed
|
|
|
|
FROM node:16-alpine AS builder
|
2022-06-11 11:27:42 +02:00
|
|
|
ARG BASE_PATH
|
|
|
|
ARG DATABASE_TYPE
|
2021-05-08 13:48:51 +02:00
|
|
|
ENV BASE_PATH=$BASE_PATH
|
2022-02-19 05:00:21 +01:00
|
|
|
ENV DATABASE_URL "postgresql://umami:umami@db:5432/umami"
|
|
|
|
ENV DATABASE_TYPE=$DATABASE_TYPE
|
2022-05-24 12:13:49 +02:00
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
|
|
COPY . .
|
2022-02-21 08:27:50 +01:00
|
|
|
|
2022-05-24 12:13:49 +02:00
|
|
|
# Next.js collects completely anonymous telemetry data about general usage.
|
|
|
|
# Learn more here: https://nextjs.org/telemetry
|
|
|
|
# Uncomment the following line in case you want to disable telemetry during the build.
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
2020-09-22 14:30:37 +02:00
|
|
|
|
2020-09-20 01:06:40 +02:00
|
|
|
RUN yarn build
|
2020-08-19 06:23:04 +02:00
|
|
|
|
2022-05-24 12:13:49 +02:00
|
|
|
# Production image, copy all the files and run next
|
|
|
|
FROM node:16-alpine AS runner
|
2020-09-22 14:30:37 +02:00
|
|
|
WORKDIR /app
|
|
|
|
|
2022-05-24 12:13:49 +02:00
|
|
|
ENV NODE_ENV production
|
|
|
|
# Uncomment the following line in case you want to disable telemetry during runtime.
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED 1
|
|
|
|
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
|
|
RUN adduser --system --uid 1001 nextjs
|
2020-09-22 14:30:37 +02:00
|
|
|
|
2022-06-12 08:38:58 +02:00
|
|
|
RUN yarn global add prisma
|
|
|
|
|
2022-05-24 12:13:49 +02:00
|
|
|
# You only need to copy next.config.js if you are NOT using the default configuration
|
|
|
|
COPY --from=builder /app/next.config.js ./
|
|
|
|
COPY --from=builder /app/public ./public
|
|
|
|
COPY --from=builder /app/package.json ./package.json
|
2022-06-12 08:38:58 +02:00
|
|
|
COPY --from=builder /app/prisma/schema.prisma ./prisma/schema.prisma
|
|
|
|
COPY --from=builder /app/prisma/migrations ./prisma/migrations
|
2020-09-22 14:30:37 +02:00
|
|
|
|
2022-06-11 11:27:42 +02:00
|
|
|
# Automatically leverage output traces to reduce image size
|
2022-05-24 12:13:49 +02:00
|
|
|
# https://nextjs.org/docs/advanced-features/output-file-tracing
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
2020-09-22 14:30:37 +02:00
|
|
|
|
2022-05-24 12:13:49 +02:00
|
|
|
USER nextjs
|
2020-09-22 14:30:37 +02:00
|
|
|
|
|
|
|
EXPOSE 3000
|
2022-05-24 12:13:49 +02:00
|
|
|
|
|
|
|
ENV PORT 3000
|
|
|
|
|
2022-06-12 08:38:58 +02:00
|
|
|
CMD ["yarn", "production"]
|