-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
39 lines (28 loc) · 1.11 KB
/
Copy pathDockerfile
File metadata and controls
39 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
FROM node:20-slim
LABEL maintainer="web-printer"
# Install LibreOffice headless and common fonts for PDF conversion.
# Using --no-install-recommends keeps the image smaller.
RUN apt-get update && apt-get install -y --no-install-recommends \
libreoffice \
fonts-liberation \
fonts-noto-cjk \
&& rm -rf /var/lib/apt/lists/*
# Verify LibreOffice is available
RUN soffice --version
WORKDIR /app
# Copy dependency manifests first to leverage Docker layer caching
COPY package.json package-lock.json ./
RUN npm ci --omit=dev
# Copy application source
COPY . .
# Ensure tmp directories exist
RUN mkdir -p tmp-uploads tmp-previews
# Create a non-root user for security
RUN groupadd -r printer && useradd -r -g printer printer \
&& chown -R printer:printer /app
USER printer
EXPOSE 3000
# Health check verifies the app can also reach the configured CUPS server.
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD node -e "require('http').get('http://localhost:3000/api/printers', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"
CMD ["npm", "start"]