FROM node:24.13.0-slim AS builder ARG ENV WORKDIR /builder COPY package*.json package-lock.json ./ RUN npm ci COPY . . RUN npx next telemetry disable RUN NODE_ENV=production npm run build FROM node:24.13.0-slim ARG ENV ENV APP_ENV=${ENV} ENV NODE_ENV=production ENV RUN_IN_CONTAINER="True" WORKDIR /app RUN chown -R node:node /app RUN apt update && apt install --no-install-recommends -y \ collectd \ curl \ jq \ openrc \ && rm -rf /var/lib/apt/lists/* COPY --from=amazon/cloudwatch-agent:latest /opt/aws/amazon-cloudwatch-agent /opt/aws/amazon-cloudwatch-agent COPY --chown=node:node docker/amazon-cloudwatch-agent.json /etc/cwagentconfig/amazon-cloudwatch-agent.json RUN mkdir -p /etc/cwagentconfig /opt/aws/amazon-cloudwatch-agent/etc \ && chown -R node:node /opt/aws/amazon-cloudwatch-agent /etc/cwagentconfig \ && mkdir -p /usr/share/collectd/ \ && touch /usr/share/collectd/types.db COPY --from=builder /builder/node_modules ./node_modules COPY --from=builder /builder/.next ./.next COPY --from=builder /builder/ecosystem* ./ COPY package*.json ./ COPY tsconfig*.json ./ COPY --chown=node:node docker/init.sh / RUN chmod +x /init.sh USER node ENTRYPOINT ["sh", "/init.sh"] CMD ["npm", "run", "start"]