forked from dendianugerah/reubah
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
72 lines (56 loc) · 1.43 KB
/
Dockerfile
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
# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /app
# Install build dependencies
RUN apk add --no-cache \
gcc \
g++ \
pkgconfig \
libwebp-dev \
musl-dev \
nodejs \
npm \
libheif-dev \
x265-dev \
libde265-dev
# Copy go.mod and go.sum first to leverage Docker cache
COPY go.mod go.sum ./
RUN go mod download
# Copy application code and build
COPY . ./
WORKDIR /app/templates
RUN npm install && npm run build
# Go back to app directory and build the application
WORKDIR /app
RUN CGO_ENABLED=1 go build -o reubah ./cmd/server
# Runtime stage
FROM alpine:3.19
WORKDIR /app
# Install runtime dependencies
RUN apk add --no-cache \
libreoffice \
ttf-liberation \
libwebp \
openjdk11-jre \
curl \
libheif-dev \
x265-dev \
libde265-dev
# Create directories for LibreOffice
RUN mkdir -p /tmp/.cache /tmp/.config /tmp/.local
# Copy binary and static files
COPY --from=builder /app/reubah /app/reubah
COPY --from=builder /app/templates ./templates
COPY --from=builder /app/static ./static
# Create non-root user
RUN addgroup -g 1000 appgroup && \
adduser -u 1000 -G appgroup -D appuser && \
chown -R appuser:appgroup /app /tmp/.cache /tmp/.config /tmp/.local
USER appuser
# Set environment variables for LibreOffice
ENV HOME=/tmp
EXPOSE 8081
# Add health check
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:8081/ || exit 1
CMD ["/app/reubah"]