45 lines
1.0 KiB
Docker
45 lines
1.0 KiB
Docker
# Build stage
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Asset URL for GCS storage
|
|
ARG NEXT_PUBLIC_ASSET_BASE_URL=https://storage.googleapis.com/orchard9-assets/research-notes
|
|
ENV NEXT_PUBLIC_ASSET_BASE_URL=$NEXT_PUBLIC_ASSET_BASE_URL
|
|
|
|
# Copy package files
|
|
COPY blog/package.json blog/package-lock.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy source
|
|
COPY blog/ .
|
|
|
|
# Build
|
|
RUN npm run build
|
|
|
|
# Runtime stage
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV PORT=3000
|
|
ENV HOSTNAME=0.0.0.0
|
|
|
|
# Don't run as root
|
|
RUN addgroup --system --gid 1001 nodejs && \
|
|
adduser --system --uid 1001 nextjs
|
|
|
|
# Copy standalone build
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
|
|
|
# Content is read at build time for SSG, but copy for any runtime needs
|
|
COPY --from=builder --chown=nextjs:nodejs /app/content ./content
|
|
|
|
USER nextjs
|
|
EXPOSE 3000
|
|
|
|
CMD ["node", "server.js"]
|