Skip to content

Commit

Permalink
chore: integrate wkhtmltopdf into docker build process
Browse files Browse the repository at this point in the history
  • Loading branch information
Salaton committed Mar 26, 2024
1 parent f9beed2 commit 6db0359
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ FROM golang:1.19 as builder
# Create and change to the app directory.
WORKDIR /app

# Install wkhtmltopdf in the builder stage.
RUN apt-get update && apt-get install -y wkhtmltopdf && apt-get clean

# Copy go.sum/go.mod and warm up the module cache (so that this
# rather long step can be cached if go.mod/go.sum don't change)
COPY go.* ./
RUN go mod download

# Set the environment variable for Gin in release mode.
ENV GIN_MODE release

# Now copy the rest.
# Now copy the rest
COPY . .

# Build the binary.
Expand All @@ -22,10 +26,16 @@ RUN CGO_ENABLED=0 GOOS=linux go build -v -o server github.com/savannahghi/clinic
# Use the official Alpine image for a lean production container.
# https://hub.docker.com/_/alpine
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
FROM alpine:3
RUN apk add --no-cache ca-certificates wkhtmltopdf
FROM alpine:3 as production

# Install ca-certificates for SSL.
RUN apk add --no-cache ca-certificates

# Copy the wkhtmltopdf binary from the builder stage to the production image.
# The path /usr/bin/wkhtmltopdf is typical for Debian-based installations; adjust if necessary.
COPY --from=builder /usr/bin/wkhtmltopdf /usr/local/bin/

# Copy the binary to the production image from the builder stage.
# Copy the Go binary to the production image from the builder stage.
COPY --from=builder /app/server /server

# Run the web service on container startup.
Expand Down

0 comments on commit 6db0359

Please sign in to comment.