Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: integrate wkhtmltopdf into docker build process #398

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading