-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDockerfile
More file actions
105 lines (88 loc) · 3.41 KB
/
Copy pathDockerfile
File metadata and controls
105 lines (88 loc) · 3.41 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# =============================================================================
# ZPL2PDF - Alpine Linux Build (Lightweight)
# =============================================================================
# This Dockerfile creates a lightweight container using Alpine Linux
# Includes fonts required for SkiaSharp text rendering
# Build: docker build -t zpl2pdf:latest .
# =============================================================================
# -----------------------------------------------------------------------------
# Stage 1: Build
# -----------------------------------------------------------------------------
FROM mcr.microsoft.com/dotnet/sdk:10.0.301 AS build
# Set working directory
WORKDIR /src
# Copy project file and restore dependencies
COPY ZPL2PDF.csproj .
COPY Resources/ ./Resources/
RUN dotnet restore ZPL2PDF.csproj
# Copy source code
COPY src/ ./src/
# Build and publish for linux-musl (Alpine).
# PublishSingleFile=false avoids MethodNotFound for SixLabors.ImageSharp in container
# (single-file can bundle mismatched assembly resolution for ImageSharp/ZXing).
RUN dotnet publish ZPL2PDF.csproj \
--configuration Release \
--runtime linux-musl-x64 \
--self-contained true \
--output /app/publish \
-p:PublishSingleFile=false \
-p:PublishReadyToRun=true \
-p:PublishTrimmed=false
# -----------------------------------------------------------------------------
# Stage 2: Runtime (Alpine Linux - Ultra Light)
# -----------------------------------------------------------------------------
FROM alpine:3.23 AS runtime
# Install runtime dependencies
# - libgdiplus: Required for System.Drawing compatibility
# - icu-libs/icu-data-full: Unicode and globalization support
# - fontconfig + fonts: Required for SkiaSharp text rendering (fixes "asset null" error)
# * ttf-dejavu: Good coverage for Western characters (~3MB)
# * ttf-liberation: Microsoft font alternatives (~2MB)
# * font-noto: Extensive Unicode coverage including accented characters (~100MB)
#
# NOTE: font-noto significantly increases image size but provides best Unicode support.
# For smaller images with basic Latin support only, remove font-noto line.
# Current image size: ~250MB (with all fonts) vs ~150MB (without font-noto)
RUN apk add --no-cache \
libgdiplus \
libintl \
icu-libs \
icu-data-full \
libstdc++ \
libgcc \
ca-certificates \
tzdata \
fontconfig \
ttf-dejavu \
ttf-liberation \
font-noto \
&& fc-cache -f
# Create non-root user
RUN addgroup -S zpl2pdf && adduser -S zpl2pdf -G zpl2pdf
# Set working directory
WORKDIR /app
# Copy entire publish output (executable + DLLs; single-file disabled for Linux)
COPY --from=build /app/publish/ .
# Create directories and set permissions
RUN mkdir -p /app/config && \
chmod +x /app/ZPL2PDF && \
chown -R zpl2pdf:zpl2pdf /app
# Switch to non-root user
USER zpl2pdf
# Set environment variables
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false \
DOTNET_RUNNING_IN_CONTAINER=true \
LC_ALL=en_US.UTF-8 \
LANG=en_US.UTF-8 \
ZPL2PDF_LANGUAGE=en-US
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD /app/ZPL2PDF status || exit 1
# Volume mount points
VOLUME ["/app/config"]
# Default command
CMD ["/app/ZPL2PDF", "run", "-l", "/app/watch"]
# Metadata
LABEL maintainer="brunoleocam" \
description="ZPL2PDF - Alpine Linux (Ultra Lightweight)" \
version="3.1.3"