Files
fredy/Dockerfile

69 lines
1.8 KiB
Docker
Raw Permalink Normal View History

2025-12-10 13:23:17 +01:00
# ================================
# Stage 1: Build stage
# ================================
FROM node:22-alpine AS builder
WORKDIR /build
# Install build dependencies needed for native modules (better-sqlite3)
RUN apk add --no-cache python3 make g++
# Copy package files first for better layer caching
COPY package.json yarn.lock ./
# Install all dependencies (including devDependencies for building)
RUN yarn config set network-timeout 600000 \
&& yarn --frozen-lockfile
# Copy source files needed for build
COPY index.html vite.config.js ./
COPY ui ./ui
COPY lib ./lib
# Build frontend assets
RUN yarn build:frontend
# ================================
# Stage 2: Production stage
# ================================
FROM node:22-alpine
2025-05-16 15:03:28 +02:00
WORKDIR /fredy
2025-05-16 14:19:20 +02:00
2025-12-10 13:23:17 +01:00
# Install Chromium and curl (for healthcheck)
# Using Alpine's chromium package which is much smaller
RUN apk add --no-cache chromium curl
2025-05-16 14:26:39 +02:00
2025-05-16 15:03:28 +02:00
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
2025-12-10 13:23:17 +01:00
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
2025-12-10 13:23:17 +01:00
# Install build dependencies for native modules, then remove them after yarn install
COPY package.json yarn.lock ./
2025-12-10 13:23:17 +01:00
RUN apk add --no-cache --virtual .build-deps python3 make g++ \
&& yarn config set network-timeout 600000 \
&& yarn --frozen-lockfile --production \
&& yarn cache clean \
&& apk del .build-deps
2025-05-16 14:26:39 +02:00
2025-12-10 13:23:17 +01:00
# Copy built frontend from builder stage
COPY --from=builder /build/ui/public ./ui/public
# Copy application source (only what's needed at runtime)
COPY index.js ./
COPY index.html ./
COPY lib ./lib
2025-05-16 14:04:55 +02:00
2025-10-06 20:21:26 +02:00
# Prepare runtime directories and symlinks for data and config
2025-05-26 13:20:12 +02:00
RUN mkdir -p /db /conf \
2025-10-06 20:21:26 +02:00
&& chown 1000:1000 /db /conf \
&& chmod 777 /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-12-10 13:23:17 +01:00
CMD ["node", "index.js"]