Skip to content

Commit

Permalink
Use docker multi-stage to build binary as well
Browse files Browse the repository at this point in the history
This relies on go modules changes
  • Loading branch information
Andy Lo-A-Foe authored and loafoe committed Jan 13, 2020
1 parent 80e019b commit 4982d67
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions 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

Expand Down

0 comments on commit 4982d67

Please sign in to comment.