2025-05-26 13:20:12 +02:00
|
|
|
FROM node:22-slim
|
2024-04-22 16:14:27 +02:00
|
|
|
|
2025-05-16 15:03:28 +02:00
|
|
|
WORKDIR /fredy
|
2025-05-16 14:19:20 +02:00
|
|
|
|
2025-09-20 19:39:48 +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 \
|
2025-09-20 19:39:48 +02:00
|
|
|
&& 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-10-01 20:04:08 +02:00
|
|
|
# Use predefined node user (UID 1000, GID 1000)
|
|
|
|
|
# Set home directory ownership for node user
|
|
|
|
|
RUN usermod -d /fredy node
|
|
|
|
|
|
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-01-04 21:50:59 +01:00
|
|
|
|
2025-05-26 13:20:12 +02:00
|
|
|
# Copy lockfiles first to leverage cache for dependencies
|
2025-10-01 20:04:08 +02:00
|
|
|
COPY --chown=node:node package.json yarn.lock .
|
2024-04-22 16:14:27 +02:00
|
|
|
|
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 \
|
2025-07-25 13:13:04 +02:00
|
|
|
&& 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-01 20:04:08 +02:00
|
|
|
COPY --chown=node:node . .
|
2025-07-25 13:13:04 +02:00
|
|
|
RUN yarn build:frontend
|
2025-05-16 14:04:55 +02:00
|
|
|
|
2025-05-26 13:20:12 +02:00
|
|
|
# Prepare runtime directories and symlinks for data and config
|
|
|
|
|
RUN mkdir -p /db /conf \
|
2025-10-01 20:04:08 +02:00
|
|
|
&& chown -R node:node /fredy /db /conf \
|
|
|
|
|
&& chmod 755 /db /conf \
|
2025-05-26 13:20:12 +02:00
|
|
|
&& ln -s /db /fredy/db \
|
|
|
|
|
&& ln -s /conf /fredy/conf
|
2024-04-22 16:14:27 +02:00
|
|
|
|
2022-01-24 16:41:23 +01:00
|
|
|
EXPOSE 9998
|
2025-09-29 12:31:32 +02:00
|
|
|
VOLUME /db
|
|
|
|
|
VOLUME /conf
|
2025-05-16 15:03:28 +02:00
|
|
|
|
2025-10-01 20:04:08 +02:00
|
|
|
# Switch to non-root user
|
|
|
|
|
USER node
|
|
|
|
|
|
2025-05-26 13:20:12 +02:00
|
|
|
# Start application using PM2 runtime
|
|
|
|
|
CMD ["pm2-runtime", "index.js"]
|