-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (48 loc) · 1.88 KB
/
Dockerfile
File metadata and controls
58 lines (48 loc) · 1.88 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
FROM oven/bun AS frontend-build
WORKDIR /src/frontend
COPY frontend/package*.json ./
RUN bun install
COPY frontend ./
RUN bun run build
# ---- Java OFD converter build ----
FROM maven:3.9-eclipse-temurin-17 AS java-builder
WORKDIR /src/ofd-converter
COPY ofd-converter/pom.xml ./
RUN mvn dependency:go-offline -q
COPY ofd-converter/src ./src
RUN mvn clean package -q -DskipTests
FROM golang:1.25 AS builder
WORKDIR /src
# copy go modules and source
COPY go.mod go.sum ./
RUN go env -w GOPROXY=https://goproxy.cn,direct
RUN go mod download
COPY . .
# Copy built frontend assets into expected location for go:embed
COPY --from=frontend-build /src/frontend/dist ./frontend/dist
# Build the Go binary (frontend must be built before this step in CI/local)
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags='-s -w' -o /out/cups-web ./cmd/server
FROM debian:bookworm-slim AS runtime
# Install LibreOffice (headless conversion) and minimal fonts/certificates
RUN apt-get update && apt-get install -y --no-install-recommends \
libreoffice-core libreoffice-writer libreoffice-calc libreoffice-impress openjdk-17-jre \
fonts-dejavu-core fonts-noto-cjk fonts-arphic-uming fonts-arphic-ukai fonts-wqy-zenhei \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user for running the service
RUN groupadd -r nonroot && useradd -r -g nonroot nonroot
RUN mkdir -p \
/home/nonroot/.cache/dconf \
/home/nonroot/.config/libreoffice \
/home/nonroot/.local/share/libreoffice \
&& chown -R nonroot:nonroot /home/nonroot/ \
&& chmod -R 755 /home/nonroot/ \
&& chmod 700 /home/nonroot/.cache/dconf
ENV DCONF_USER_CONFIG_DIR=/home/nonroot/.config/dconf
ENV HOME=/home/nonroot
ENV XDG_CACHE_HOME=/home/nonroot/.cache
COPY --from=builder /out/cups-web /cups-web
COPY --from=java-builder /src/ofd-converter/target/ofd-converter.jar /ofd-converter.jar
EXPOSE 8080
USER nonroot
ENTRYPOINT ["/cups-web"]