2026-01-14 18:11:42 +01:00
|
|
|
FROM node:20-alpine
|
2022-06-20 19:05:25 +02:00
|
|
|
|
|
|
|
|
# Set working directory
|
|
|
|
|
WORKDIR /usr/app
|
|
|
|
|
|
|
|
|
|
# Install PM2 globally
|
|
|
|
|
RUN npm install --global pm2
|
|
|
|
|
|
|
|
|
|
# Copy package.json and package-lock.json before other files
|
|
|
|
|
# Utilise Docker cache to save re-installing dependencies if unchanged
|
|
|
|
|
COPY ./package*.json ./
|
|
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
|
RUN npm install --production
|
|
|
|
|
|
|
|
|
|
# Copy all files
|
|
|
|
|
COPY ./ ./
|
|
|
|
|
|
2023-05-25 11:32:38 +02:00
|
|
|
COPY /docker/entrypoint.sh ./entrypoint.sh
|
|
|
|
|
|
2022-06-20 19:05:25 +02:00
|
|
|
# Build app
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
2023-05-25 11:32:38 +02:00
|
|
|
RUN chmod u+x /usr/app/entrypoint.sh
|
|
|
|
|
|
2022-06-20 19:05:25 +02:00
|
|
|
# Expose the listening port
|
|
|
|
|
EXPOSE 3000
|
|
|
|
|
|
2023-05-25 11:32:38 +02:00
|
|
|
# apply env variables to the Nextjs .env file
|
|
|
|
|
ENTRYPOINT ["/usr/app/entrypoint.sh"]
|
2022-06-20 19:05:25 +02:00
|
|
|
|
2023-05-25 11:32:38 +02:00
|
|
|
CMD npm run start
|