Files
fredy/Dockerfile

41 lines
1.1 KiB
Docker
Raw Normal View History

2025-05-26 13:20:12 +02:00
FROM node:22-slim
2025-05-16 15:03:28 +02:00
WORKDIR /fredy
2025-05-16 14:19:20 +02:00
# Install Chromium and curl without extra recommended packages and clean apt cache
# curl is needed for the health check
2025-05-26 13:20:12 +02:00
RUN apt-get update \
&& apt-get install -y --no-install-recommends chromium curl \
2025-05-26 13:20:12 +02:00
&& rm -rf /var/lib/apt/lists/*
2025-05-16 14:26:39 +02:00
2025-05-16 15:03:28 +02:00
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
2025-05-26 12:07:22 +02:00
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
2025-05-26 13:20:12 +02:00
# Copy lockfiles first to leverage cache for dependencies
2025-10-06 19:55:37 +02:00
COPY --chown=node:node package.json yarn.lock ./
2025-05-26 13:20:12 +02:00
# Set Yarn timeout, install dependencies and PM2 globally
2025-05-26 12:07:22 +02:00
RUN yarn config set network-timeout 600000 \
&& yarn --frozen-lockfile \
2025-05-26 13:20:12 +02:00
&& yarn global add pm2
2025-05-16 14:26:39 +02:00
2025-05-26 13:20:12 +02:00
# Copy application source and build production assets
2025-10-06 19:55:37 +02:00
COPY --chown=node:node . .
RUN yarn build:frontend
2025-05-16 14:04:55 +02:00
2025-10-06 19:55:37 +02:00
# Prepare runtime directories and symlinks for data and config (as root)
2025-05-26 13:20:12 +02:00
RUN mkdir -p /db /conf \
2025-10-06 19:55:37 +02:00
&& chown node:node /fredy /db /conf \
&& chmod 770 /db /conf \
2025-05-26 13:20:12 +02:00
&& ln -s /db /fredy/db \
&& ln -s /conf /fredy/conf
EXPOSE 9998
VOLUME /db
VOLUME /conf
2025-05-16 15:03:28 +02:00
2025-10-06 19:55:37 +02:00
# Change to non-root user
USER node
2025-05-26 13:20:12 +02:00
# Start application using PM2 runtime
2025-10-06 19:55:37 +02:00
CMD ["pm2-runtime", "index.js"]