Skip to content

Commit

Permalink
feat: use docker multi-stage build to eliminate dependencies on exter…
Browse files Browse the repository at this point in the history
…nal environments
  • Loading branch information
halalala222 committed Aug 4, 2024
1 parent 393d1cf commit ef04a09
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
FROM ubuntu:18.04
FROM golang:alpine as go-builder

RUN go env -w CGO_ENABLED=0

WORKDIR /build

COPY go.mod go.sum ./

RUN go mod download

COPY . .

RUN go build -trimpath -ldflags '-extldflags "-static -fpic" -s -w' -o ./flydb-server cmd/server/cli/flydb-server.go

FROM alpine:latest

WORKDIR /app

COPY bin/flydb-server /app/flydb-server
COPY --from=go-builder /build/flydb-server /app/flydb-server

RUN chmod +x /app/flydb-server

CMD ["/app/flydb-server"]
EXPOSE 8999

ENTRYPOINT ["/app/flydb-server"]

0 comments on commit ef04a09

Please sign in to comment.