umami/Dockerfile

58 lines
1.7 KiB
Docker
Raw Normal View History

# Install dependencies only when needed
2023-03-12 20:45:46 +01:00
FROM --platform=linux/amd64 node:18-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 ./
# Add yarn timeout to handle slow CPU when Github Actions
2023-03-12 18:35:36 +01:00
RUN yarn config set network-timeout 300000
RUN yarn install --frozen-lockfile
# Rebuild the source code only when needed
FROM --platform=linux/amd64 node:18-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
2022-08-23 19:49:45 +02:00
RUN yarn build-docker
2020-08-19 06:23:04 +02:00
# Production image, copy all the files and run next
2023-03-12 20:45:46 +01:00
FROM --platform=linux/amd64 node:18-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 .
2022-08-09 22:36:24 +02:00
COPY --from=builder --chown=nextjs:nodejs /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"]