Reduce go binary size be removing symbol table

Optimize binary file size to perform deployment faster.
This commit is contained in:
Akshay Gaikwad
2022-06-13 15:24:16 +05:30
parent e736febc33
commit 0c1b581dd3
4 changed files with 16 additions and 6 deletions

View File

@@ -8,9 +8,9 @@ COPY go.sum .
RUN go mod download
COPY . .
RUN go build github.com/paralus/paralus
RUN make build
FROM alpine:latest as runtime
FROM scratch as runtime
LABEL description="Run container"
COPY --from=build /build/paralus /usr/bin/paralus
@@ -19,5 +19,9 @@ WORKDIR /usr/bin
# TODO: Support paralus binary to run migrations
COPY ./persistence/migrations/admindb /data/migrations/admindb
# RPC port
EXPOSE 10000
# RPC relay peering port
EXPOSE 10001
# HTTP port
EXPOSE 11000

View File

@@ -4,9 +4,9 @@ LABEL description="Build container"
ENV CGO_ENABLED 0
COPY . /build
WORKDIR /build
RUN go build -o paralus-init scripts/initialize/main.go
RUN go build -ldflags "-s" -o paralus-init scripts/initialize/main.go
FROM alpine:latest as runtime
FROM scratch as runtime
LABEL description="Run container"
WORKDIR /usr/bin

View File

@@ -4,9 +4,9 @@ LABEL description="Build container"
ENV CGO_ENABLED 0
COPY . /build
WORKDIR /build
RUN go build -o start-sync scripts/kratos/providers_sync.go
RUN go build -ldflags "-s" -o start-sync scripts/kratos/providers_sync.go
FROM alpine:latest as runtime
FROM scratch as runtime
LABEL description="Run container"
WORKDIR /usr/bin

View File

@@ -5,6 +5,12 @@ tidy:
vendor:
go mod vendor
.PHONY: build
build:
# Omit the symbol table and debug information to reduce the
# size of binary.
go build -ldflags "-s" -o rcloud-base .
.PHONY: build-proto
build-proto:
buf build