Skip to content
Browse files

Use docker multi-stage to build binary as well

This relies on go modules changes
  • Loading branch information
Andy Lo-A-Foe authored and loafoe committed Mar 29, 2019
1 parent 80e019b commit 4982d674b56f6243ea2775b7746fe426c0e48dc1
Showing with 20 additions and 2 deletions.
  1. +20 −2 Dockerfile
@@ -1,7 +1,25 @@
# Build with modules
FROM golang:1.12.1-alpine as builder
RUN apk add --no-cache ca-certificates curl git build-base

# Get dependencies first for docker caching
WORKDIR /fhirbase
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy source
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags netgo -ldflags '-w -extldflags "-static"'

FROM postgres:10.5
WORKDIR /fhirbase

COPY demo/bundle.ndjson.gzip .
COPY bin/fhirbase-linux-amd64 /usr/bin/fhirbase
COPY --from=builder /fhirbase/demo/bundle.ndjson.gzip .
COPY --from=builder /fhirbase/fhirbase /usr/bin/fhirbase
COPY --from=builder /fhirbase/schema /fhirbase/schema
COPY --from=builder /fhirbase/transform /fhirbase/transform
COPY --from=builder /fhirbase/web /fhirbase/web

RUN chmod +x /usr/bin/fhirbase

0 comments on commit 4982d67

Please sign in to comment.
You can’t perform that action at this time.