port-nimara-client-portal/Dockerfile

47 lines
1.0 KiB
Docker
Raw Normal View History

2025-02-16 13:10:19 +01:00
ARG NODE_VERSION=20.10.0
ARG PORT=3000
FROM node:${NODE_VERSION}-slim as base
ENV NODE_ENV=production
ENV NODE_OPTIONS=--max-old-space-size=8192
WORKDIR /app
FROM base as build
COPY package.json .
COPY package-lock.json .
RUN npm install --production=false
COPY . .
RUN npm run build
RUN npm prune
FROM base as production
ENV PORT=$PORT
# Install PM2 and required tools
RUN apt-get update && apt-get install -y \
curl \
tini \
&& rm -rf /var/lib/apt/lists/* \
&& npm install -g pm2
# Copy built application
2025-02-16 13:10:19 +01:00
COPY --from=build /app/.output /app/.output
# Copy PM2 config and entrypoint
COPY ecosystem.config.js /app/
COPY docker-entrypoint.sh /app/
RUN chmod +x /app/docker-entrypoint.sh
# Create logs directory
RUN mkdir -p /app/logs
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:${PORT}/api/health || exit 1
# Use tini as init process
ENTRYPOINT ["/usr/bin/tini", "--"]
# Start with our custom entrypoint
CMD ["/app/docker-entrypoint.sh"]