2026-08-08 07:25:17 +00:00
|
|
|
FROM node:20-alpine
|
|
|
|
|
|
2026-08-08 07:31:01 +00:00
|
|
|
# Install curl explicitly for the healthcheck (wget in alpine has had IPv6/connection-resolved quirks)
|
|
|
|
|
RUN apk add --no-cache curl
|
|
|
|
|
|
2026-08-08 07:25:17 +00:00
|
|
|
# Create app directory and data directory for the persistent volume
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
RUN mkdir -p /data
|
|
|
|
|
|
|
|
|
|
# Install dependencies (cached layer)
|
|
|
|
|
COPY package.json ./
|
|
|
|
|
RUN npm install --omit=dev --no-audit --no-fund && npm cache clean --force
|
|
|
|
|
|
|
|
|
|
# Copy the rest of the app
|
|
|
|
|
COPY . .
|
|
|
|
|
|
|
|
|
|
# Defaults — override these in Coolify's Environment section
|
|
|
|
|
ENV PORT=3000 \
|
|
|
|
|
DATA_FILE=/data/data.json \
|
|
|
|
|
NODE_ENV=production
|
|
|
|
|
|
|
|
|
|
EXPOSE 3000
|
|
|
|
|
|
|
|
|
|
# Healthcheck for Coolify / orchestrators
|
2026-08-08 07:31:01 +00:00
|
|
|
# Use 127.0.0.1 (IPv4 explicit) to avoid IPv6 connection-refused races.
|
|
|
|
|
# Generous start-period because Node + Alpine cold-start can take ~30-60s on first deploy.
|
|
|
|
|
HEALTHCHECK --interval=20s --timeout=5s --start-period=60s --retries=8 \
|
|
|
|
|
CMD curl -fsS http://127.0.0.1:3000/api/health || exit 1
|
2026-08-08 07:25:17 +00:00
|
|
|
|
|
|
|
|
# Run as non-root for safety
|
|
|
|
|
RUN addgroup -S app && adduser -S app -G app && chown -R app:app /app /data
|
|
|
|
|
USER app
|
|
|
|
|
|
|
|
|
|
CMD ["node", "server.js"]
|