umami/Dockerfile

56 lines
1.5 KiB
Docker
Raw Normal View History

# 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
# Rebuild the source code only when needed
FROM node:16-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
2022-06-14 20:32:21 +02:00
ARG DATABASE_TYPE
2022-06-22 20:02:40 +02:00
ARG BASE_PATH
2022-06-14 20:32:21 +02:00
ENV DATABASE_TYPE $DATABASE_TYPE
2022-06-22 20:02:40 +02:00
ENV BASE_PATH $BASE_PATH
ENV NEXT_TELEMETRY_DISABLED 1
RUN yarn build
2020-08-19 06:23:04 +02:00
# Production image, copy all the files and run next
FROM node:16-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
RUN yarn add npm-run-all dotenv prisma
2022-06-12 08:38:58 +02:00
# You only need to copy next.config.js if you are NOT using the default configuration
2022-06-27 19:34:03 +02:00
COPY --from=builder /app/next.config.js .
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
2022-06-27 19:34:03 +02:00
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/scripts ./scripts
2022-06-11 11:27:42 +02:00
# Automatically leverage output traces to reduce image size
# 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
USER nextjs
EXPOSE 3000
ENV PORT 3000
2022-06-22 10:50:33 +02:00
CMD ["yarn", "start-docker"]