fix docker build

This commit is contained in:
Christian Kellner
2025-05-15 10:16:43 +02:00
parent 4bab3bd9da
commit 9a09548a07
2 changed files with 48 additions and 21 deletions

View File

@@ -1,25 +1,33 @@
FROM node:20
WORKDIR /fredy
# 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/*
COPY . /fredy
# Set working directory
WORKDIR /fredy
RUN apt-get update && apt-get install -y chromium
# Copy only package.json + yarn.lock for dependency caching
COPY package.json yarn.lock ./
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
RUN yarn install
# Increase network timeout for npm registry
RUN yarn config set network-timeout 600000 && yarn install
# Global tools (cached separately)
RUN yarn global add pm2
# Copy application source code (after deps, cache friendly)
COPY . .
# Build step (assuming 'prod' is a build script)
RUN yarn run prod
# Prepare runtime dirs
RUN mkdir /db /conf && \
chown 1000:1000 /db /conf && \
chmod 777 -R /db/ && \
ln -s /db /fredy/db && ln -s /conf /fredy/conf
chown 1000:1000 /db /conf && \
chmod 777 -R /db/ && \
ln -s /db /fredy/db && ln -s /conf /fredy/conf
# Expose port & set runtime command
EXPOSE 9998
CMD pm2-runtime index.js
CMD ["pm2-runtime", "index.js"]