forked from PDFCraftTool/pdfcraft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (45 loc) · 1.97 KB
/
Copy pathDockerfile
File metadata and controls
57 lines (45 loc) · 1.97 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# =============================================================================
# PDFCraft Production Dockerfile
# Multi-stage build for optimized image size
# Optimized with BuildKit cache mounts for faster builds
# =============================================================================
# syntax=docker/dockerfile:1
# -----------------------------------------------------------------------------
# Stage 1: Build the Next.js static export
# -----------------------------------------------------------------------------
FROM node:22-alpine AS builder
WORKDIR /app
# Install dependencies first (better layer caching)
# Use BuildKit cache mount to persist npm cache across builds
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm ci --ignore-scripts
# Copy source code
COPY . .
# Build the static export
# Use BuildKit cache mount for Next.js cache to speed up rebuilds
ARG BASE_PATH=""
ENV BASE_PATH=$BASE_PATH
ENV DOCKER_BUILD=true
RUN --mount=type=cache,target=/root/.npm \
--mount=type=cache,target=/app/.next/cache \
npm run build
# -----------------------------------------------------------------------------
# Stage 2: Serve with Nginx
# -----------------------------------------------------------------------------
FROM nginx:1.25-alpine AS production
# Add labels for GitHub Container Registry
LABEL org.opencontainers.image.source="https://github.com/PDFCraftTool/pdfcraft"
LABEL org.opencontainers.image.description="PDFCraft - Professional PDF Tools, Free, Private & Browser-Based"
LABEL org.opencontainers.image.licenses="AGPL-3.0"
LABEL org.opencontainers.image.title="PDFCraft"
LABEL org.opencontainers.image.vendor="PDFCraftTool"
# Copy custom nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY security-headers.conf /etc/nginx/security-headers.conf
# Copy the static export from builder stage
COPY --from=builder /app/out /website/pdfcraft
# Expose port 80
EXPOSE 80
# Start Nginx
CMD ["nginx", "-g", "daemon off;"]