content: # syntax=docker/dockerfile:1.19@sha256:b6afd42430b15f2d2a4c5a02b919e98a525b785b1aaff16747d2f623364e39b6
  
  # Base stage
  FROM node:24-alpine@sha256:77f3c4d1f33c17dfa4af4b0add57d86957187873e313c2c37f52831d117645c8 AS base
  ENV TZ=UTC
  ENV NPM_CONFIG_UPDATE_NOTIFIER=false
  RUN apk add --no-cache openssl && \
    mkdir /app && \
    chown -R node:node /app
  ENV NEXT_TELEMETRY_DISABLED=1
  USER node
  WORKDIR /app
  
  # Dependencies stage
  FROM base AS builder
  COPY --chown=node:node ui/package.json ui/package-lock.json ./
  RUN npm ci
  COPY --chown=node:node ui/ .
  RUN npm run build
  
  # Builder stage
  FROM base AS runner
  ENV NODE_ENV=production
  
  COPY --from=builder /app/public ./public
  
  # Automatically leverage output traces to reduce image size
  # https://nextjs.org/docs/advanced-features/output-file-tracing
  COPY --from=builder /app/.next/standalone .
  COPY --from=builder /app/.next/static ./.next/static
  COPY --chown=node:node stacks/ui/ui-entrypoint.sh /app/entrypoint.sh
  
  EXPOSE 3000
  
  ENV PORT=3000
  # set hostname to localhost
  ENV HOSTNAME=0.0.0.0
  
  ARG PEERDB_VERSION_SHA_SHORT
  ENV PEERDB_VERSION_SHA_SHORT=${PEERDB_VERSION_SHA_SHORT}
  
  ENTRYPOINT ["/app/entrypoint.sh"]
  CMD ["node", "server.js"]
  