Skip to content

Commit

Permalink
chore: update dockerfile to include template folder copying
Browse files Browse the repository at this point in the history
  • Loading branch information
Salaton committed Mar 26, 2024
1 parent d3f289c commit dfc83aa
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Use the official Golang image to create a build artifact.
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang:1.19 as builder

# Create and change to the app directory.
Expand All @@ -9,34 +8,36 @@ 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.sum/go.mod and warm up the module cache.
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 of the application's source code
COPY . .

# Build the binary.
RUN CGO_ENABLED=0 GOOS=linux go build -v -o server github.com/savannahghi/clinical

# 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 as production

# Install ca-certificates for SSL.
# Install ca-certificates and other runtime dependencies for wkhtmltopdf.
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 the wkhtmltopdf binary and related files from the builder stage to the production image.
COPY --from=builder /usr/bin/wkhtmltopdf /usr/local/bin/

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

# Ensure your templates directory is correctly copied into the Docker image.
COPY --from=builder /app/templates /app/templates

# Set the working directory to where your binary and templates are
WORKDIR /app

# Run the web service on container startup.
CMD ["/server"]

0 comments on commit dfc83aa

Please sign in to comment.