Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not run pm2 runtime with nextjs? #5809

Closed
Caesar-APAX opened this issue Apr 29, 2024 · 0 comments
Closed

Can not run pm2 runtime with nextjs? #5809

Caesar-APAX opened this issue Apr 29, 2024 · 0 comments

Comments

@Caesar-APAX
Copy link

Caesar-APAX commented Apr 29, 2024

# Base on offical Node.js image
FROM node:18-alpine

# Pnpm with docker
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2

# Set working directory
WORKDIR /usr/app

# Install PM2 globally
RUN pnpm install pm2 --global

# Copy files to docker
COPY ./ ./

# Install dependencies
RUN pnpm install --production --frozen-lockfile

# Build app
RUN pnpm build

# Expose the listening port
EXPOSE 3000

WORKDIR /usr/app
RUN mkdir /usr/app/pm2
RUN mkdir /usr/app/pm2/logs
RUN chmod -R 777 /usr/app/pm2/

# Show current folder structure in logs
WORKDIR /usr/app

CMD ["pm2-runtime", "start", "pm2.config.js"]
module.exports = {
  apps: [
    {
      name: 'next',
      exec_mode: 'cluster',
      instances: 1,
      args: 'start',
      cwd: '/usr/app/',
      script: './node_modules/next/dist/bin/next',
      watch: false,
      autorestart: true,
      combine_logs: true,
      exp_backoff_restart_delay: 100,
      ignore_watch: ['node_modules'],
      log_date_format: 'YYYY-MM-DD HH:mm Z',
      error_file: './pm2/logs/next_err.log'
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant