2024-09-12 12:05:07 +00:00
|
|
|
FROM fascinated/docker-images:nodejs_20_with_pnpm AS base
|
2024-09-11 14:48:18 +00:00
|
|
|
|
2024-09-30 08:02:16 +00:00
|
|
|
# Install dependencies and build tools for canvas
|
2024-09-11 14:48:18 +00:00
|
|
|
FROM base AS deps
|
2024-09-30 08:03:14 +00:00
|
|
|
RUN apk add --no-cache python3 make g++ gcc pkgconfig pixman cairo-dev libjpeg-turbo-dev pango-dev giflib-dev
|
2024-09-11 14:48:18 +00:00
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json* pnpm-lock.yaml* ./
|
|
|
|
RUN pnpm install --frozen-lockfile --quiet
|
|
|
|
|
|
|
|
# Build from source
|
|
|
|
FROM base AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
|
|
COPY . .
|
2024-09-30 08:02:16 +00:00
|
|
|
|
2024-09-30 08:08:34 +00:00
|
|
|
# Install runtime dependencies
|
2024-09-30 08:11:12 +00:00
|
|
|
RUN apk add --no-cache cairo pango libjpeg-turbo giflib
|
2024-09-30 08:02:16 +00:00
|
|
|
|
2024-09-23 22:53:07 +00:00
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
2024-09-11 14:48:18 +00:00
|
|
|
|
2024-09-13 19:54:34 +00:00
|
|
|
# Add the commit hash
|
|
|
|
ARG GIT_REV
|
2024-09-23 22:53:07 +00:00
|
|
|
ENV GIT_REV=${GIT_REV}
|
2024-09-13 19:54:34 +00:00
|
|
|
|
2024-09-30 08:20:48 +00:00
|
|
|
# Add the sentry auth token
|
|
|
|
ARG SENTRY_AUTH_TOKEN
|
|
|
|
ENV SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN}
|
|
|
|
|
2024-09-11 14:48:18 +00:00
|
|
|
# Build the app
|
|
|
|
RUN pnpm run build
|
|
|
|
|
2024-09-30 08:02:16 +00:00
|
|
|
# Final stage to run the app
|
2024-09-11 14:48:18 +00:00
|
|
|
FROM base AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
|
2024-09-30 08:08:34 +00:00
|
|
|
# Install runtime dependencies
|
2024-09-30 08:11:12 +00:00
|
|
|
RUN apk add --no-cache cairo pango libjpeg-turbo giflib
|
2024-09-30 07:46:25 +00:00
|
|
|
|
2024-09-23 22:53:07 +00:00
|
|
|
ENV NODE_ENV=production
|
|
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
2024-09-11 14:48:18 +00:00
|
|
|
|
|
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
|
|
|
|
RUN mkdir .next
|
|
|
|
RUN chown nextjs:nodejs .next
|
|
|
|
|
2024-09-24 09:53:03 +00:00
|
|
|
# Add the commit hash
|
|
|
|
ARG GIT_REV
|
|
|
|
ENV GIT_REV=${GIT_REV}
|
|
|
|
|
2024-09-30 08:02:16 +00:00
|
|
|
# Copy the built app from the builder stage
|
2024-09-23 22:30:04 +00:00
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/node_modules ./node_modules
|
2024-09-11 14:48:18 +00:00
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/package.json ./package.json
|
2024-09-11 14:52:25 +00:00
|
|
|
COPY --from=builder --chown=nextjs:nodejs /app/next.config.mjs ./next.config.mjs
|
2024-09-11 14:48:18 +00:00
|
|
|
|
|
|
|
USER nextjs
|
2024-09-24 09:37:30 +00:00
|
|
|
|
|
|
|
EXPOSE 3000
|
2024-09-24 10:11:18 +00:00
|
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
ENV PORT=3000
|
2024-09-24 09:37:30 +00:00
|
|
|
|
2024-09-23 22:57:45 +00:00
|
|
|
CMD ["pnpm", "start"]
|