2024-07-24 09:39:27 +02:00
|
|
|
FROM node:20
|
2024-04-22 16:14:27 +02:00
|
|
|
|
2025-05-15 10:16:43 +02:00
|
|
|
# Install chromium dependencies in a separate layer (cacheable)
|
|
|
|
|
RUN apt-get update && apt-get install -y chromium && \
|
|
|
|
|
apt-get clean && rm -rf /var/lib/apt/lists/*
|
2024-04-22 16:14:27 +02:00
|
|
|
|
2025-05-15 10:16:43 +02:00
|
|
|
# Set working directory
|
|
|
|
|
WORKDIR /fredy
|
2024-04-22 16:14:27 +02:00
|
|
|
|
2025-05-15 10:16:43 +02:00
|
|
|
# Copy only package.json + yarn.lock for dependency caching
|
|
|
|
|
COPY package.json yarn.lock ./
|
2025-01-04 21:50:59 +01:00
|
|
|
|
2025-05-15 10:16:43 +02:00
|
|
|
# Increase network timeout for npm registry
|
|
|
|
|
RUN yarn config set network-timeout 600000 && yarn install
|
2024-04-22 16:14:27 +02:00
|
|
|
|
2025-05-15 10:16:43 +02:00
|
|
|
# Global tools (cached separately)
|
2024-04-22 16:14:27 +02:00
|
|
|
RUN yarn global add pm2
|
|
|
|
|
|
2025-05-15 10:16:43 +02:00
|
|
|
# Copy application source code (after deps, cache friendly)
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
# Build step (assuming 'prod' is a build script)
|
2022-01-24 16:41:23 +01:00
|
|
|
RUN yarn run prod
|
|
|
|
|
|
2025-05-15 10:16:43 +02:00
|
|
|
# Prepare runtime dirs
|
2022-01-24 16:41:23 +01:00
|
|
|
RUN mkdir /db /conf && \
|
2025-05-15 10:16:43 +02:00
|
|
|
chown 1000:1000 /db /conf && \
|
|
|
|
|
chmod 777 -R /db/ && \
|
|
|
|
|
ln -s /db /fredy/db && ln -s /conf /fredy/conf
|
2024-04-22 16:14:27 +02:00
|
|
|
|
2025-05-15 10:16:43 +02:00
|
|
|
# Expose port & set runtime command
|
2022-01-24 16:41:23 +01:00
|
|
|
EXPOSE 9998
|
2025-05-15 10:16:43 +02:00
|
|
|
CMD ["pm2-runtime", "index.js"]
|