-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
72 lines (59 loc) · 1.53 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
# Builder to copy wkhtmltopdf binaries for alpine for latest version 0.12.6
FROM surnet/alpine-wkhtmltopdf:3.16.2-0.12.6-full as wkhtmltopdf
# wkhtmltopdf install dependencies
RUN apk add --no-cache \
libstdc++ \
libx11 \
libxrender \
libxext \
libssl1.1 \
ca-certificates \
fontconfig \
freetype \
ttf-droid \
ttf-freefont \
ttf-liberation \
# more fonts
;
# Use Build stage for compiling the go app
FROM golang:1.22-alpine AS BuildStage
# Install wkhtmltopdf
ENV DIR=/usr/local/bin/
#Change directory so that our commands run inside this new directory
WORKDIR $DIR
#Copy wkhtmltopdf binaries
COPY --from=wkhtmltopdf /bin/wkhtmltopdf /bin/libwkhtmltox.so /bin/
RUN apk add build-base
#CHange back to main Dir
WORKDIR /app
# Copy and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the source code
COPY . .
# Build the Go application
RUN CGO_ENABLED=1 go build -o pdf-service .
# Deploy the application
# Must use 3.18.5, as since 3.19 libssl is giving issues
FROM alpine:3.18.5
WORKDIR /app
COPY --from=BuildStage /bin/wkhtmltopdf /bin/libwkhtmltox.so /bin/
COPY --from=BuildStage /app/ .
# Set the timezone and install CA certificates
RUN apk --no-cache add ca-certificates \
tzdata \
libstdc++ \
libx11 \
libxrender \
libxext \
ca-certificates \
fontconfig \
freetype \
ttf-droid \
ttf-freefont \
ttf-liberation \
libssl1.1
EXPOSE 3000
#USER noroot:noroot
#Start the container with the application
ENTRYPOINT ["/app/pdf-service"]